Expand description
§Rust GTK 4 bindings
The project website is here.
Rust bindings of GTK 4, part of gtk4-rs.
This library contains safe Rust bindings for GTK 4, a multi-platform GUI toolkit. It is a part of gtk-rs.
Most of this documentation is generated from the C API. Until all parts of the documentation have been reviewed there will be incongruities with the actual Rust API.
For a gentle introduction to gtk-rs we recommend the online book GUI development with Rust and GTK 4.
See also:
- gtk-rs project overview
- General
GLib
family types and object system overview - GTK documentation
- GTK Visual Index
§Minimum supported Rust version
Currently, the minimum supported Rust version is 1.70
.
§“Hello, World!” example program
GTK needs to be initialized before use by calling init
. Creating an
Application
will call init
for you.
The gtk4
crate is usually renamed to gtk
. You can find an example in
the features section for how to do this globally in your Cargo.toml
.
use gtk4 as gtk;
use gtk::prelude::*;
use gtk::{glib, Application, ApplicationWindow};
fn main() -> glib::ExitCode {
let app = Application::builder()
.application_id("org.example.HelloWorld")
.build();
app.connect_activate(|app| {
// We create the main window.
let window = ApplicationWindow::builder()
.application(app)
.default_width(320)
.default_height(200)
.title("Hello, World!")
.build();
// Show the window.
window.present();
});
app.run()
}
§The main loop
In a typical GTK application you set up the UI, assign signal handlers and run the main event loop.
use gtk4 as gtk;
use gtk::prelude::*;
use gtk::{glib, Application, ApplicationWindow, Button};
fn main() -> glib::ExitCode {
let application = Application::builder()
.application_id("com.example.FirstGtkApp")
.build();
application.connect_activate(|app| {
let window = ApplicationWindow::builder()
.application(app)
.title("First GTK Program")
.default_width(350)
.default_height(70)
.build();
let button = Button::with_label("Click me!");
button.connect_clicked(|_| {
eprintln!("Clicked!");
});
window.set_child(Some(&button));
window.present();
});
application.run()
}
§Threads
GTK is not thread-safe. Accordingly, none of this crate’s structs implement
Send
or Sync
.
The thread where init
was called is considered the main thread. OS X has
its own notion of the main thread and init
must be called on that thread.
After successful initialization, calling any gtk
or gdk
functions (including init
) from other threads will panic
.
Any thread can schedule a closure to be run by the main loop on the main
thread via glib::idle_add
or
glib::timeout_add
. While
working with GTK you might need the glib::idle_add_local
or glib::timeout_add_local
version without the
Send
bound. Those may only be called from the main thread.
§Panics
The gtk
and gdk
crates have some run-time safety and contract
checks.
-
Any constructor or free function will panic if called before
init
or on a non-main thread. -
Any
&str
or&Path
parameter with an interior null (\0
) character will cause a panic. -
Some functions will panic if supplied out-of-range integer parameters. All such cases will be documented individually but they are not yet.
-
A panic in a closure that handles signals or in any other closure passed to a
gtk
function will abort the process.
§Features
§Library versions
By default this crate provides only GTK 4.0 APIs. You can access additional
functionality by selecting one of the v4_2
, v4_4
, etc. features.
Cargo.toml
example:
[dependencies.gtk]
package = "gtk4"
version = "0.x.y"
features = ["v4_2"]
Take care when choosing the version to target: some of your users might not have easy access to the latest ones. The higher the version, the fewer users will have it installed.
§Documentation
- The Rust API Stable/Development
- Book Stable/Development
- Examples
- The C API
- GTK Installation Instructions
§Using
We recommend using crates from crates.io, as demonstrated here.
If you want to track the bleeding edge, use the git dependency instead:
[dependencies]
gtk = { git = "https://github.com/gtk-rs/gtk4-rs.git", package = "gtk4" }
Avoid mixing versioned and git crates like this:
# This will not compile
[dependencies]
gdk = {version = "0.1", package = "gdk4"}
gtk = { git = "https://github.com/gtk-rs/gtk4-rs.git", package = "gtk4" }
§Features
Feature | Description |
---|---|
v4_16 | Enable the new APIs part of GTK 4.16 |
v4_14 | Enable the new APIs part of GTK 4.14 |
v4_12 | Enable the new APIs part of GTK 4.12 |
v4_10 | Enable the new APIs part of GTK 4.10 |
v4_8 | Enable the new APIs part of GTK 4.8 |
v4_6 | Enable the new APIs part of GTK 4.6 |
v4_4 | Enable the new APIs part of GTK 4.4 |
v4_2 | Enable the new APIs part of GTK 4.2 |
gnome_46 | Enable all version feature flags of this crate and its dependencies to match the GNOME 46 SDK |
gnome_45 | Enable all version feature flags of this crate and its dependencies to match the GNOME 45 SDK |
gnome_44 | Enable all version feature flags of this crate and its dependencies to match the GNOME 44 SDK |
gnome_43 | Enable all version feature flags of this crate and its dependencies to match the GNOME 43 SDK |
gnome_42 | Enable all version feature flags of this crate and its dependencies to match the GNOME 42 SDK |
unsafe-assume-initialized | Disable checks that gtk is initialized, for use in C ABI libraries |
xml_validation | Enable xml_validation feature of gtk4-macros |
blueprint | Enable blueprint feature of gtk4-macros |
§See Also
§License
The Rust bindings of gtk4 are available under the MIT License, please refer to it.
Re-exports§
pub use subclass::widget::TemplateChild;
pub use cairo;
pub use ffi;
pub use gdk;
pub use gdk_pixbuf;
pub use gio;
pub use glib;
pub use graphene;
pub use gsk;
pub use pango;
Modules§
- Builder pattern types.
- Traits intended for blanket imports.
- Traits intended for creating custom types.
Structs§
ATContext
is an abstract class provided by GTK to communicate to platform-specific assistive technologies API.- The
AboutDialog
offers a simple way to display information about a program. Accessible
is an interface for describing UI elements for Assistive Technologies.- AccessibleList
v4_14
A boxed type which wraps a list of references to GtkAccessible objects. - AccessibleRange
v4_10
This interface describes ranged controls, e.g. controls which have a single value within an allowed range and that can optionally be changed by the user. ActionBar
is designed to present contextual actions.- The
Actionable
interface provides a convenient way of associating widgets with actions. - A
ShortcutAction
that calls gtk_widget_activate(). Adjustment
is a model for a numeric value.- AlertDialog
v4_10
AAlertDialog
object collects the arguments that are needed to present a message to the user. - A
ShortcutTrigger
that combines two triggers. AnyFilter
matches an item when at least one of its filters matches.- AppChooserDeprecatedThe application selection widgets should be implemented according to the design of each platform and/or application requiring them.
AppChooser
is an interface for widgets which allow the user to choose an application. - AppChooserButtonDeprecatedThe application selection widgets should be implemented according to the design of each platform and/or application requiring them. The
AppChooserButton
lets the user select an application. - AppChooserDialogDeprecatedThe application selection widgets should be implemented according to the design of each platform and/or application requiring them.
AppChooserDialog
shows aAppChooserWidget
inside aDialog
. - AppChooserWidgetDeprecatedThe application selection widgets should be implemented according to the design of each platform and/or application requiring them.
AppChooserWidget
is a widget for selecting applications. Application
is a high-level API for writing applications.- Types of user actions that may be blocked by
Application
. AspectFrame
preserves the aspect ratio of its child.- AssistantDeprecatedThis widget will be removed in GTK 5
Assistant
is used to represent a complex as a series of steps. - AssistantPageDeprecatedThis object will be removed in GTK 5
AssistantPage
is an auxiliary object used by `GtkAssistant. BinLayout
is aLayoutManager
subclass useful for create “bins” of widgets.- A
Bitset
represents a set of unsigned integers. - An opaque, stack-allocated struct for iterating over the elements of a
Bitset
. BookmarkList
is a list model that wrapsGBookmarkFile
.BoolFilter
evaluates a booleanExpression
to determine whether to include items.- A struct that specifies a border around a rectangular area.
- The
Box
widget arranges child widgets into a single row or column. BoxLayout
is a layout manager that arranges children in a single row or column.Buildable
allows objects to extend and customize their deserialization from ui files.- A
Builder
reads XML descriptions of a user interface and instantiates the described objects. - The list of flags that can be passed to gtk_builder_create_closure().
BuilderListItemFactory
is aListItemFactory
that creates widgets by instantiatingBuilder
UI templates.- An implementation of
BuilderScope
that can bind Rust callbacks. BuilderScope
is an interface to provide language binding support toBuilder
.- The
Button
widget is generally used to trigger a callback function that is called when the button is pressed. Calendar
is a widget that displays a Gregorian calendar, one month at a time.- A
ShortcutAction
that invokes a callback. - CellAreaDeprecatedList views use widgets for displaying their contents An abstract class for laying out
CellRenderer
s - CellAreaBoxDeprecatedList views use widgets for displaying their contents A cell area that renders GtkCellRenderers into a row or a column
- CellAreaContextDeprecatedThis object will be removed in GTK 5 Stores geometrical information for a series of rows in a GtkCellArea
- CellEditableDeprecatedList views use widgets for displaying their contents. See
Editable
for editable text widgets Interface for widgets that can be used for editing cells - CellLayoutDeprecatedList views use widgets to display their contents. See
LayoutManager
for layout manager delegate objects An interface for packing cells - CellRendererDeprecatedList views use widgets for displaying their contents An object for rendering a single cell
- CellRendererAccelDeprecatedApplications editing keyboard accelerators should provide their own implementation according to platform design guidelines Renders a keyboard accelerator in a cell
- CellRendererComboDeprecatedList views use widgets to display their contents. You should use
DropDown
instead Renders a combobox in a cell - CellRendererPixbufDeprecated
- CellRendererProgressDeprecatedList views use widgets to display their contents. You should use
ProgressBar
instead Renders numbers as progress bars - CellRendererSpinDeprecatedList views use widgets to display their contents. You should use
SpinButton
instead Renders a spin button in a cell - CellRendererSpinnerDeprecatedList views use widgets to display their contents. You should use
Spinner
instead Renders a spinning animation in a cell - Tells how a cell is to be rendered.
- CellRendererTextDeprecatedList views use widgets to display their contents. You should use
Inscription
orLabel
instead Renders text in a cell - CellRendererToggleDeprecatedList views use widgets to display their contents. You should use
ToggleButton
instead Renders a toggle button in a cell - CellViewDeprecatedList views use widgets to display their contents. You can use
Box
instead A widget displaying a single row of a GtkTreeModel CenterBox
arranges three children in a row, keeping the middle child centered as well as possible.CenterLayout
is a layout manager that manages up to three children.- A
CheckButton
places a label next to an indicator. - An expression using a custom
GClosure
to compute the value from its parameters. - ColorButtonDeprecatedUse
ColorDialogButton
instead TheColorButton
allows to open a color chooser dialog to change the color. - ColorChooserDeprecatedUse
ColorDialog
andColorDialogButton
instead of widgets implementingColorChooser
ColorChooser
is an interface that is implemented by widgets for choosing colors. - ColorChooserDialogDeprecatedUse
ColorDialog
instead A dialog for choosing a color. - ColorChooserWidgetDeprecatedDirect use of
ColorChooserWidget
is deprecated. TheColorChooserWidget
widget lets the user select a color. - ColorDialog
v4_10
AColorDialog
object collects the arguments that are needed to present a color chooser dialog to the user, such as a title for the dialog and whether it should be modal. - ColorDialogButton
v4_10
TheColorDialogButton
is a wrapped around aColorDialog
and allows to open a color chooser dialog to change the color. ColumnView
presents a large dynamic list of items using multiple columns with headers.- ColumnViewCell
v4_12
ColumnViewColumn
represents the columns being added to aColumnView
.- ColumnViewRow
v4_12
ColumnViewRow
is used byColumnView
to allow configuring how rows are displayed. - ColumnViewSorter
v4_10
ColumnViewSorter
is a sorter implementation that is geared towards the needs ofColumnView
. - ComboBoxDeprecated
- ComboBoxTextDeprecatedUse
DropDown
with aStringList
instead AComboBoxText
is a simple variant ofComboBox
for text-only use cases. - A constant value in a
Expression
. Constraint
describes a constraint between attributes of two widgets, expressed as a linear equation.- A
ConstraintGuide
is an invisible layout element in aConstraintLayout
. - A layout manager using constraints to describe relations between widgets.
LayoutChild
subclass for children in aConstraintLayout
.- The
ConstraintTarget
interface is implemented by objects that can be used as source or target inConstraint
s. CssProvider
is an object implementing theStyleProvider
interface for CSS.- Defines a part of a CSS document.
CustomFilter
determines whether to include items with a callback.CustomSorter
is aSorter
implementation that sorts via a callback function.- Flags to use with gtk_set_debug_flags().
- DialogDeprecatedUse
Window
instead Dialogs are a convenient way to prompt the user for a small amount of input. - Flags used to influence dialog construction.
DirectoryList
is a list model that wraps g_file_enumerate_children_async().DragSource
is an event controller to initiate Drag-And-Drop operations.DrawingArea
is a widget that allows drawing with cairo.DropControllerMotion
is an event controller tracking the pointer during Drag-and-Drop operations.DropDown
is a widget that allows the user to choose an item from a list of options.DropTarget
is an event controller to receive Drag-and-Drop operations.DropTargetAsync
is an event controller to receive Drag-and-Drop operations, asynchronously.Editable
is an interface for text editing widgets.- A
EditableLabel
is a label that allows users to edit the text by switching to an “edit mode”. - The
EmojiChooser
is used by text widgets such asEntry
orTextView
to let users insert Emoji characters. Entry
is a single line text entry widget.- A
EntryBuffer
hold the text displayed in aText
widget. - EntryCompletionDeprecated
EntryCompletion
is an auxiliary object to provide completion functionality forEntry
. EventController
is the base class for event controllers.EventControllerFocus
is an event controller to keep track of keyboard focus.EventControllerKey
is an event controller that provides access to key events.EventControllerLegacy
is an event controller that provides raw access to the event stream.EventControllerMotion
is an event controller tracking the pointer position.EventControllerScroll
is an event controller that handles scroll events.- Describes the behavior of a
EventControllerScroll
. EveryFilter
matches an item when each of its filters matches.Expander
allows the user to reveal its child by clicking on an expander triangle.Expression
provides a way to describe references to values.- An opaque structure representing a watched
Expression
. - FileChooserDeprecatedUse
FileDialog
insteadFileChooser
is an interface that can be implemented by file selection widgets. - FileChooserDialogDeprecatedUse
FileDialog
insteadFileChooserDialog
is a dialog suitable for use with “File Open” or “File Save” commands. - FileChooserNativeDeprecatedUse
FileDialog
insteadFileChooserNative
is an abstraction of a dialog suitable for use with “File Open” or “File Save as” commands. - FileChooserWidgetDeprecatedDirect use of
FileChooserWidget
is deprecatedFileChooserWidget
is a widget for choosing files. - FileDialog
v4_10
AFileDialog
object collects the arguments that are needed to present a file chooser dialog to the user, such as a title for the dialog and whether it should be modal. FileFilter
filters files by name or mime type.- FileLauncher
v4_10
AFileLauncher
object collects the arguments that are needed to open a file with an application. - A
Filter
object describes the filtering to be performed by aFilterListModel
. FilterListModel
is a list model that filters the elements of the underlying model according to aFilter
.Fixed
places its child widgets at fixed positions and with fixed sizes.FixedLayout
is a layout manager which can place child widgets at fixed positions.LayoutChild
subclass for children in aFixedLayout
.FlattenListModel
is a list model that concatenates other list models.- A
FlowBox
puts child widgets in reflowing grid. FlowBoxChild
is the kind of widget that can be added to aFlowBox
.- FontButtonDeprecatedUse
FontDialogButton
instead TheFontButton
allows to open a font chooser dialog to change the font. - FontChooserDeprecatedUse
FontDialog
andFontDialogButton
insteadFontChooser
is an interface that can be implemented by widgets for choosing fonts. - FontChooserDialogDeprecatedUse
FontDialog
instead TheFontChooserDialog
widget is a dialog for selecting a font. - Specifies the granularity of font selection that is desired in a
FontChooser
. - FontChooserWidgetDeprecatedDirect use of
FontChooserWidget
is deprecated. TheFontChooserWidget
widget lets the user select a font. - FontDialog
v4_10
AFontDialog
object collects the arguments that are needed to present a font chooser dialog to the user, such as a title for the dialog and whether it should be modal. - FontDialogButton
v4_10
TheFontDialogButton
is wrapped around aFontDialog
and allows to open a font chooser dialog to change the font. Frame
is a widget that surrounds its child with a decorative frame and an optional label.GLArea
is a widget that allows drawing with OpenGL.Gesture
is the base class for gesture recognition.GestureClick
is aGesture
implementation for clicks.GestureDrag
is aGesture
implementation for drags.GestureLongPress
is aGesture
for long presses.GesturePan
is aGesture
for pan gestures.GestureRotate
is aGesture
for 2-finger rotations.GestureSingle
is aGtkGestures
subclass optimized for singe-touch and mouse gestures.GestureStylus
is aGesture
specific to stylus input.GestureSwipe
is aGesture
for swipe gestures.GestureZoom
is aGesture
for 2-finger pinch/zoom gestures.- GraphicsOffload
v4_14
A widget that allows to bypass gsk rendering for its child by passing the content directly to the compositor. Grid
is a container which arranges its child widgets in rows and columns.GridLayout
is a layout manager which arranges child widgets in rows and columns.LayoutChild
subclass for children in aGridLayout
.GridView
presents a large dynamic grid of items.HeaderBar
is a widget for creating custom title bars for windows.IMContext
defines the interface for GTK input methods.IMContextSimple
is an input method supporting table-based input methods.IMMulticontext
is an input method context supporting multiple, switchable input methods.- Used to specify options for gtk_icon_theme_lookup_icon().
- Contains information found when looking up an icon in
IconTheme
. IconTheme
provides a facility for loading themed icons.- IconViewDeprecated
- The
Image
widget displays an image. - InfoBarDeprecated
- Describes hints that might be taken into account by input methods or applications.
- Inscription
v4_8
Inscription
is a widget to show text in a predefined area. - A
ShortcutTrigger
that triggers when a specific keyval and modifiers are pressed. - The
Label
widget displays a small amount of text. LayoutChild
is the base class for objects that are meant to hold layout properties.- Layout managers are delegate classes that handle the preferred size and the allocation of a widget.
LevelBar
is a widget that can be used as a level indicator.- A
LinkButton
is a button with a hyperlink. ListBase
is the abstract base class for GTK’s list widgets.ListBox
is a vertical list.ListBoxRow
is the kind of widget that can be added to aListBox
.- ListHeader
v4_12
ListHeader
is used by list widgets to represent the headers they display. ListItem
is used by list widgets to represent items in agio::ListModel
.- A
ListItemFactory
creates widgets for the items taken from aGListModel
. - ListScrollFlags
v4_12
List of actions to perform when scrolling to items in a list widget. - ListStoreDeprecatedUse
Gio::ListStore
instead A list-like data structure that can be used with theTreeView
. ListView
presents a large dynamic list of items.- LockButtonDeprecatedThis widget will be removed in GTK 5
LockButton
is a widget to obtain and revoke authorizations needed to operate the controls. - A
MapListModel
maps the items in a list model to different items. MediaControls
is a widget to show controls for a video.MediaFile
implementsMediaStream
for files.MediaStream
is the integration point for media playback inside GTK.- The
MenuButton
widget is used to display a popup when clicked. - MessageDialogDeprecatedUse
AlertDialog
insteadMessageDialog
presents a dialog with some message text. - A
ShortcutAction
that calls gtk_widget_mnemonic_activate(). - A
ShortcutTrigger
that triggers when a specific mnemonic is pressed. MountOperation
is an implementation ofGMountOperation
.MultiFilter
is the base class for filters that combine multiple filters.MultiSelection
is aSelectionModel
that allows selecting multiple elements.MultiSorter
combines multiple sorters by trying them in turn.- A
ShortcutAction
that activates an action by name. Native
is the interface implemented by all widgets that have their owngdk::Surface
.- Native dialogs are platform dialogs that don’t use
Dialog
. - A
ShortcutTrigger
that never triggers. NoSelection
is aSelectionModel
that does not allow selecting anything.Notebook
is a container whose children are pages switched between using tabs.NotebookPage
is an auxiliary object used byNotebook
.- A
ShortcutAction
that does nothing. NumericSorter
is aSorter
that compares numbers.- A
GObject
value in aExpression
. - The
Orientable
interface is implemented by all widgets that can be oriented horizontally or vertically. Overlay
is a container which contains a single main child, on top of which it can place “overlay” widgets.OverlayLayout
is the layout manager used byOverlay
.LayoutChild
subclass for children in aOverlayLayout
.- Struct defining a pad action entry.
PadController
is an event controller for the pads found in drawing tablets.- A range of pages to print.
- A
PageSetup
object stores the page size, orientation and margins. - PageSetupUnixDialogLinux
PageSetupUnixDialog
implements a page setup dialog for platforms which don’t provide a native page setup dialog, like Unix. - A widget with two panes, arranged either horizontally or vertically.
PaperSize
handles paper sizes.- A
GParamSpec
for properties holding aExpression
. PasswordEntry
is an entry that has been tailored for entering secrets.- A
EntryBuffer
that locks the underlying memory to prevent it from being swapped to disk. - Flags that influence the behavior of
WidgetExt::pick()
. - The
Picture
widget displays agdk::Paintable
. Popover
is a bubble-like context popup.PopoverMenu
is a subclass ofPopover
that implements menu behavior.PopoverMenuBar
presents a horizontal bar of items that pop up popover menus when clicked.- Flags that affect how
PopoverMenu
widgets built from agio::MenuModel
are created and displayed. - PrintCapabilitiesLinuxSpecifies which features the print dialog should offer.
- A
PrintContext
encapsulates context information that is required when drawing pages for printing. - PrintDialog
v4_14
APrintDialog
object collects the arguments that are needed to present a print dialog to the user, such as a title for the dialog and whether it should be modal. - PrintJobLinuxA
PrintJob
object represents a job that is sent to a printer. PrintOperation
is the high-level, portable printing API.PrintOperationPreview
is the interface that is used to implement print preview.- A
PrintSettings
object represents the settings of a print dialog in a system-independent way. - PrintSetup
v4_14
APrintSetup
is an auxiliary object for printing that allows decoupling the setup from the printing. - PrintUnixDialogLinux
PrintUnixDialog
implements a print dialog for platforms which don’t provide a native print dialog, like Unix. - PrinterLinuxA
Printer
object represents a printer. ProgressBar
is typically used to display the progress of a long running operation.- A
GObject
property value in aExpression
. Range
is the common base class for widgets which visualize an adjustment.- Meta-data to be passed to gtk_recent_manager_add_full() when registering a recently used resource.
RecentInfo
contains the metadata associated with an item in the recently used files list.RecentManager
manages and looks up recently used files.- A
Requisition
represents the desired size of a widget. See GtkWidget’s geometry management section for more information. - A
Revealer
animates the transition of its child from invisible to visible. Root
is the interface implemented by all widgets that can act as a toplevel widget.- A
Scale
is a slider control used to select a numeric value. ScaleButton
provides a button which pops up a scale widget.- ScrollInfo
v4_12
TheScrollInfo
can be used to provide more accurate data on how a scroll operation should be performed. Scrollable
is an interface for widgets with native scrolling ability.- The
Scrollbar
widget is a horizontal or vertical scrollbar. ScrolledWindow
is a container that makes its child scrollable.SearchBar
is a container made to have a search entry.SearchEntry
is an entry widget that has been tailored for use as a search entry.- SectionModel
v4_12
SectionModel
is an interface that adds support for sections to list models. SelectionFilterModel
is a list model that presents the selection from aSelectionModel
.SelectionModel
is an interface that add support for selection to list models.Separator
is a horizontal or vertical separator widget.Settings
provides a mechanism to share global settings between applications.- A
Shortcut
describes a keyboard shortcut. ShortcutAction
encodes an action that can be triggered by a keyboard shortcut.- List of flags that can be passed to action activation.
ShortcutController
is an event controller that manages shortcuts.ShortcutLabel
displays a single keyboard shortcut or gesture.- The
ShortcutManager
interface is used to implement shortcut scopes. ShortcutTrigger
tracks how aShortcut
should be activated.- A
ShortcutsGroup
represents a group of related keyboard shortcuts or gestures. - A
ShortcutsSection
collects all the keyboard shortcuts and gestures for a major application mode. - A
ShortcutsShortcut
represents a single keyboard shortcut or gesture with a short text. - A
ShortcutsWindow
shows information about the keyboard shortcuts and gestures of an application. - A
Shortcut
Action that emits a signal. SignalListItemFactory
is aListItemFactory
that emits signals to manage listitems.SingleSelection
is aSelectionModel
that allows selecting a single item.SizeGroup
groups widgets together so they all request the same size.SliceListModel
is a list model that presents a slice of another model.Snapshot
assists in creatinggsk::RenderNode
s for widgets.- A
GListModel
that sorts the elements of an underlying model according to aSorter
. Sorter
is an object to describe sorting criteria.- A
SpinButton
is an ideal way to allow the user to set the value of some attribute. - A
Spinner
widget displays an icon-size spinning animation. Stack
is a container which only shows one of its children at a time.- A
StackSidebar
uses a sidebar to switch betweenStack
pages. - The
StackSwitcher
shows a row of buttons to switch betweenStack
pages. - Describes a widget state.
- StatusbarDeprecated
StringFilter
determines whether to include items by comparing strings to a fixed search term.StringList
is a list model that wraps an array of strings.StringObject
is the type of items in aStringList
.StringSorter
is aSorter
that compares strings.- StyleContextDeprecatedThe relevant API has been moved to
Widget
where applicable; otherwise, there is no replacement for querying the style machinery. Stylable UI elements should use widgets.StyleContext
stores styling information affecting a widget. - Flags that modify the behavior of gtk_style_context_to_string().
StyleProvider
is an interface for style information used byStyleContext
.Switch
is a “light switch” that has two states: on or off.SymbolicPaintable
is an interface that support symbolic colors in paintables.- The
Text
widget is a single-line text entry widget. - Stores text and attributes for display in a
TextView
. - A
TextChildAnchor
is a spot in aTextBuffer
where child widgets can be “anchored”. - An iterator for the contents of a
TextBuffer
. - A
TextMark
is a position in aGtkTextbuffer
that is preserved across modifications. - Flags affecting how a search is done.
- A tag that can be applied to text contained in a
TextBuffer
. - The collection of tags in a
TextBuffer
- A widget that displays the contents of a
TextBuffer
. - A
ToggleButton
is a button which remains “pressed-in” when clicked. Tooltip
is an object representing a widget tooltip.- TreeDragDestDeprecatedList views use widgets to display their contents. You can use
DropTarget
to implement a drop destination Interface for Drag-and-Drop destinations inTreeView
. - TreeDragSourceDeprecatedList views use widgets to display their contents. You can use
DragSource
to implement a drag source Interface for Drag-and-Drop destinations inTreeView
. TreeExpander
is a widget that provides an expander for a list.TreeListModel
is a list model that can create child models on demand.TreeListRow
is used byTreeListModel
to represent items.TreeListRowSorter
is a special-purpose sorter that will apply a given sorter to the levels in a tree.- TreeModelDeprecatedUse
gio::ListModel
instead The tree interface used by GtkTreeView - TreeModelFilterDeprecatedUse
FilterListModel
instead. ATreeModel
which hides parts of an underlying tree model - TreeModelFlagsDeprecatedThese flags indicate various properties of a
TreeModel
. - TreeModelSortDeprecatedUse
SortListModel
instead A GtkTreeModel which makes an underlying tree model sortable - An opaque structure representing a path to a row in a model.
- A GtkTreeRowReference tracks model changes so that it always refers to the same row (a
TreePath
refers to a position, not a fixed row). Create a new GtkTreeRowReference with gtk_tree_row_reference_new(). - TreeSelectionDeprecatedUse
SelectionModel
instead The selection object for GtkTreeView - TreeSortableDeprecatedThere is no replacement for this interface. You should use
SortListModel
to wrap your list model instead The interface for sortable models used by GtkTreeView - TreeStoreDeprecatedUse
TreeListModel
instead A tree-like data structure that can be used with theTreeView
. - TreeViewDeprecatedUse
ListView
for lists, andColumnView
for tabular lists A widget for displaying both trees and lists - TreeViewColumnDeprecatedUse
ColumnView
andColumnViewColumn
instead ofTreeView
to show a tabular list A visible column in aTreeView
widget - UriLauncher
v4_10
AUriLauncher
object collects the arguments that are needed to open a uri with an application. Video
is a widget to show aMediaStream
with media controls.Viewport
implements scrollability for widgets that lack their own scrolling capabilities.- VolumeButtonDeprecatedThis widget will be removed in GTK 5
VolumeButton
is aScaleButton
subclass tailored for volume control. - The base class for all widgets.
WidgetPaintable
is agdk::Paintable
that displays the contents of a widget.- A
Window
is a toplevel window which can contain other widgets. WindowControls
shows window frame controls.WindowGroup
makes group of windows behave like separate applications.WindowHandle
is a titlebar area widget.
Enums§
- The priority of an accessibility announcement.
- The possible values for the
AccessibleProperty::Autocomplete
accessible property. - The possible values for the
AccessibleState::Invalid
accessible state. - The various platform states which can be queried using
AccessibleExt::platform_state()
. - The possible accessible properties of a
Accessible
. - The possible accessible relations of a
Accessible
. - The accessible role for a
Accessible
implementation. - The possible values for the
AccessibleProperty::Sort
accessible property. - The possible accessible states of a
Accessible
. - The possible values for the
AccessibleState::Pressed
accessible state. - Controls how a widget deals with extra space in a single dimension.
- Used to indicate the direction in which an arrow should point.
- Determines the page role inside a
Assistant
. - Baseline position in a row of widgets.
- Describes how the border of a UI element should be rendered.
- Error codes that identify various errors that can occur while using
Builder
. - Prebuilt sets of buttons for
Dialog
. - The available modes for
accel-mode
. - Identifies how the user can interact with a particular cell.
- Collation
v4_10
Describes how aStringSorter
turns strings into sort keys to compare them. - The widget attributes that can be used when creating a
Constraint
. - The relation between two terms of a constraint.
- The strength of a constraint, expressed as a symbolic constant.
- Domain for VFL parsing errors.
- ContentFit
v4_8
Controls how a content should be made to fit inside an allocation. - Specifies which corner a child widget should be placed in when packed into a
ScrolledWindow
- Errors that can occur while parsing CSS.
- Warnings that can occur while parsing CSS.
- Passed to various keybinding signals for deleting text.
- DialogError
v4_10
Error codes in theGTK_DIALOG_ERROR
domain that can be returned by async dialog functions. - Focus movement types.
- The identifiers for
Editable
properties. - Specifies the side of the entry at which an icon is placed.
- Describes the state of a
gdk::EventSequence
in aGesture
. - Describes whether a
FileChooser
is being used to open existing files or to save to a possibly new file. - These identify the various errors that can occur while calling
FileChooser
functions. - Describes changes in a filter in more detail and allows objects using the filter to optimize refiltering items.
- Describes the known strictness of a filter.
- FontLevel
v4_10
The level of granularity for the font selection. - FontRendering
v4_16
Values for thegtk-font-rendering
setting that influence how GTK renders fonts. - Represents the state of graphics offloading.
- Built-in icon sizes.
- Error codes for
IconTheme
operations. - An enum for determining where a dropped item goes.
- Describes the image data representation used by a
Image
. - Describes primary purpose of the input widget.
- The different methods to handle text in #GtkInscription when it doesn’t fit the available space.
- Used for justifying the text inside a
Label
widget. - Describes how
LevelBar
contents should be rendered. - The type of license for an application.
- ListTabBehavior
v4_12
Used to configure the focus behavior in theGTK_DIR_TAB_FORWARD
andGTK_DIR_TAB_BACKWARD
direction, like the Tab key in aListView
. - The type of message being displayed in a
MessageDialog
. - Passed as argument to various keybinding signals for moving the cursor position.
- NaturalWrapMode
v4_6
Options for selecting a different wrap mode for natural size requests. - The parameter used in the action signals of
Notebook
. - Used to determine the layout of pages on a sheet when printing multiple pages per sheet.
- Describes the way two values can be compared.
- Represents the orientation of widgets and other objects.
- Defines how content overflowing a given area should be handled.
- Represents the packing location of a children in its parent.
- The type of a pad action.
- See also gtk_print_settings_set_orientation().
- See also gtk_print_job_set_page_set().
- Describes the panning direction of a
GesturePan
. - Determines how the size should be computed to achieve the one of the visibility mode for the scrollbars.
- Describes which edge of a widget a certain feature is positioned at.
- See also gtk_print_settings_set_duplex().
- Error codes that identify various errors that can occur while using the GTK printing support.
- Determines what action the print operation should perform.
- The result of a print operation.
- See also gtk_print_job_set_pages()
- See also gtk_print_settings_set_quality().
- The status gives a rough indication of the completion of a running print operation.
- Describes limits of a
EventController
for handling events targeting other widgets. - Describes the stage at which events are fed into a
EventController
. - Error codes for
RecentManager
operations - Predefined values for use as response ids in gtk_dialog_add_button().
- These enumeration values describe the possible transitions when the child of a
Revealer
widget is shown or hidden. - Passed as argument to various keybinding signals.
- Scrolling types.
- Defines the policy to be used in a scrollable widget when updating the scrolled window adjustments in a given orientation.
- Used to control what selections users are allowed to make.
- Determines how GTK handles the sensitivity of various controls, such as combo box buttons.
- Describes where
Shortcut
s added to aShortcutController
get handled. - GtkShortcutType specifies the kind of shortcut that is being described.
- The mode of the size group determines the directions in which the size group affects the requested sizes of its component widgets.
- Specifies a preference for height-for-width or width-for-height geometry management.
- SortColumnDeprecated
- Determines the direction of a sort.
- Describes changes in a sorter in more detail and allows users to optimize resorting.
- Describes the type of order that a
Sorter
may produce. - Determines whether the spin button displays values outside the adjustment bounds.
- The values of the GtkSpinType enumeration are used to specify the change to make in gtk_spin_button_spin().
- Possible transitions between pages in a
Stack
widget. - Specifies how search strings are matched inside text.
- SymbolicColor
v4_6
The indexes of colors passed to symbolic color rendering, such asvfunc::Gtk::SymbolicPaintable::snapshot_symbolic
. - Values that can be passed to the
WidgetImpl::system_setting_changed()
vfunc. - Reading directions for text.
- Granularity types that extend the text selection. Use the
GtkTextView::extend-selection
signal to customize the selection. - Used to reference the layers of
TextView
for the purpose of customized drawing with the ::snapshot_layer vfunc. - Used to reference the parts of
TextView
. - The sizing method the column uses to determine its width. Please note that
Autosize
are inefficient for large views, and can make columns appear choppy. - An enum for determining where a dropped row goes.
- Used to indicate which grid lines to draw in a tree view.
- See also gtk_print_settings_set_paper_width().
- Describes a type of line wrapping.
Constants§
- An undefined value. The accessible attribute is either unset, or its value is undefined.
- The value used to refer to a guaranteed invalid position in a
GListModel
. - Use this priority for functionality related to size allocation.
- A priority that can be used when adding a
StyleProvider
for application-specific style information. - The priority used for default style information that is used in the absence of themes.
- The priority used for style information provided via
Settings
. - The priority used for style information provided by themes.
- The priority used for the style information from
$XDG_CONFIG_HOME/gtk-4.0/gtk.css
. - The priority at which the text view validates onscreen lines in an idle job in the background.
Statics§
- An attribute for the background color, expressed as an RGB value encoded in a string using the format:
{r8},{g8},{b8}
. - An attribute for the font family name.
- An attribute for the foreground color, expressed as an RGB value encoded in a string using the format:
{r8},{g8},{b8}
. - An attribute for the overline style.
- The “none” overline value for
Gtk::ACCESSIBLE_ATTRIBUTE_OVERLINE
. - The “single” overline value for
Gtk::ACCESSIBLE_ATTRIBUTE_OVERLINE
. - An attribute for the font size, expressed in points.
- An attribute for the font stretch type.
- The “condensed” stretch value for
Gtk::ACCESSIBLE_ATTRIBUTE_STRETCH
. - The “expanded” stretch value for
Gtk::ACCESSIBLE_ATTRIBUTE_STRETCH
. - The “extra condensed” stretch value for
Gtk::ACCESSIBLE_ATTRIBUTE_STRETCH
. - The “extra expanded” stretch value for
Gtk::ACCESSIBLE_ATTRIBUTE_STRETCH
. - The “normal” stretch value for
Gtk::ACCESSIBLE_ATTRIBUTE_STRETCH
. - The “semi condensed” stretch value for
Gtk::ACCESSIBLE_ATTRIBUTE_STRETCH
. - The “semi expanded” stretch value for
Gtk::ACCESSIBLE_ATTRIBUTE_STRETCH
. - The “ultra condensed” stretch value for
Gtk::ACCESSIBLE_ATTRIBUTE_STRETCH
. - The “ultra expanded” stretch value for
Gtk::ACCESSIBLE_ATTRIBUTE_STRETCH
. - An attribute for strikethrough text.
- An attribute for the font style.
- The “italic” style value for
Gtk::ACCESSIBLE_ATTRIBUTE_STYLE
. - The “normal” style value for
Gtk::ACCESSIBLE_ATTRIBUTE_STYLE
. - The “oblique” style value for
Gtk::ACCESSIBLE_ATTRIBUTE_STYLE
. - An attribute for the underline style.
- The “double” underline value for
Gtk::ACCESSIBLE_ATTRIBUTE_UNDERLINE
. - The “error” underline value for
Gtk::ACCESSIBLE_ATTRIBUTE_UNDERLINE
. - The “none” underline value for
Gtk::ACCESSIBLE_ATTRIBUTE_UNDERLINE
. - The “single” underline value for
Gtk::ACCESSIBLE_ATTRIBUTE_UNDERLINE
. - An attribute for the font variant.
- The “all petite caps” variant value for
Gtk::ACCESSIBLE_ATTRIBUTE_VARIANT
. - The “all small caps” variant value for
Gtk::ACCESSIBLE_ATTRIBUTE_VARIANT
. - The “petite caps” variant value for
Gtk::ACCESSIBLE_ATTRIBUTE_VARIANT
. - The “small caps” variant value for
Gtk::ACCESSIBLE_ATTRIBUTE_VARIANT
. - The “title caps” variant value for
Gtk::ACCESSIBLE_ATTRIBUTE_VARIANT
. - The “unicase” variant value for
Gtk::ACCESSIBLE_ATTRIBUTE_VARIANT
. - An attribute for the font weight.
- The name used for the stock full offset included by
LevelBar
. - The name used for the stock high offset included by
LevelBar
. - The name used for the stock low offset included by
LevelBar
. - Name for the A3 paper size.
- Name for the A4 paper size.
- Name for the A5 paper size.
- Name for the B5 paper size.
- Name for the Executive paper size.
- Name for the Legal paper size.
- Name for the Letter paper size.
- The key used by the “Print to file” printer to store the file name of the output without the path to the directory and the file extension.
- The key used by the “Print to file” printer to store the directory to which the output should be written.
- The key used by the “Print to file” printer to store the format of the output. The supported values are “PS” and “PDF”.
- The key used by the “Print to file” printer to store the URI to which the output should be written. GTK itself supports only “file://” URIs.
Functions§
- Gets the modifier mask.
- Converts an accelerator keyval and modifier mask into a string which can be used to represent the accelerator to the user.
- Converts an accelerator keyval and modifier mask into a string that can be displayed to the user.
- Converts an accelerator keyval and modifier mask into a string parseable by gtk_accelerator_parse().
- Converts an accelerator keyval and modifier mask into a string parseable by gtk_accelerator_parse_with_keycode().
- Parses a string representing an accelerator.
- Parses a string representing an accelerator.
- Determines whether a given keyval and modifier mask constitute a valid keyboard accelerator.
- Returns the binary age as passed to
libtool
. - Checks that the GTK library in use is compatible with the given version.
- Returns the GTK debug flags that are currently active.
- Returns the
pango::Language
for the default language currently in effect. - enumerate_printersLinuxCalls a function for all
Printer
s. - Converts a color from HSV space to RGB.
- Tries to initialize GTK.
- Returns the interface age as passed to
libtool
. - Returns
true
if GTK has been initialized. - Returns
true
if GTK has been initialized and this is the main thread. - Get the direction of the current locale. This is the expected reading direction for text and UI.
- Returns the major version number of the GTK library.
- Returns the micro version number of the GTK library.
- Returns the minor version number of the GTK library.
- Runs a page setup dialog, letting the user modify the values from @page_setup. If the user cancels the dialog, the returned
PageSetup
is identical to the passed in @page_setup, otherwise it contains the modifications done in the dialog. - Runs a page setup dialog, letting the user modify the values from @page_setup.
- render_activityDeprecatedRenders an activity indicator (such as in
Spinner
). The stateStateFlags::CHECKED
determines whether there is activity going on. - render_arrowDeprecatedRenders an arrow pointing to @angle.
- render_backgroundDeprecatedRenders the background of an element.
- render_checkDeprecatedRenders a checkmark (as in a
CheckButton
). - render_expanderDeprecatedRenders an expander (as used in
TreeView
andExpander
) in the area defined by @x, @y, @width, @height. The stateStateFlags::CHECKED
determines whether the expander is collapsed or expanded. - render_focusDeprecatedRenders a focus indicator on the rectangle determined by @x, @y, @width, @height.
- render_frameDeprecatedRenders a frame around the rectangle defined by @x, @y, @width, @height.
- render_handleDeprecated
- render_iconDeprecatedRenders the icon in @texture at the specified @x and @y coordinates.
- render_layoutDeprecatedRenders @layout on the coordinates @x, @y
- render_lineDeprecatedRenders a line from (x0, y0) to (x1, y1).
- render_optionDeprecatedRenders an option mark (as in a radio button), the
StateFlags::CHECKED
state will determine whether the option is on or off, andStateFlags::INCONSISTENT
whether it should be marked as undefined. - Converts a color from RGB space to HSV.
- Sets the GTK debug flags.
- Informs this crate that GTK has been initialized and the current thread is the main one.
- A convenience function for showing an application’s about dialog.
- show_uriDeprecatedThis function launches the default application for showing a given uri, or shows an error dialog if that fails.
- show_uri_fullDeprecatedThis function launches the default application for showing a given uri.
- show_uri_full_futureDeprecated
- Checks whether the
Accessible
has @property set. - Checks whether the
Accessible
has @relation set. - Checks whether the
GtkAccessible:accessible-role
of the accessible is @role. - Checks whether the
Accessible
has @state set. - Return the type ids that have been registered after calling gtk_test_register_all_types().
- Force registration of all core GTK object types.
- Enters the main loop and waits for @widget to be “drawn”.
- tree_create_row_drag_contentDeprecatedCreates a content provider for dragging @path from @tree_model.
- tree_get_row_drag_dataDeprecatedObtains a @tree_model and @path from value of target type
GTK_TYPE_TREE_ROW_DATA
.