Crate gtk [] [src]

GTK+ 3 bindings

This library contains safe Rust bindings for GTK+ 3, a multi-platform GUI toolkit. It's a part of Gtk-rs.

The library is a work in progress: expect missing bindings and breaking changes. A steadily increasing share of the code is machine-generated from GObject introspection metadata. The API docs were converted from the upstream ones so until they've all been reviewed there will be incongruities with actual Rust APIs.

See also:

Hello World

extern crate gtk;
use gtk::prelude::*;
use gtk::{ButtonsType, DialogFlags, MessageType, MessageDialog, Window};

fn main() {
    if gtk::init().is_err() {
        println!("Failed to initialize GTK.");
        return;
    }
    MessageDialog::new(None::<&Window>,
                       DialogFlags::empty(),
                       MessageType::Info,
                       ButtonsType::Ok,
                       "Hello World").run();
}

Initialization

GTK+ needs to be initialized before use by calling init or Application::new. You only need to do it once and there is no 'finalize'.

The main loop

In a typical GTK+ application you set up the UI, assign signal handlers and run the main event loop:

fn main() {
    gtk::init().unwrap();
    // Create the main window.
    let window = Window::new(WindowType::Toplevel);
    // UI initialization.
    // ...
    // Don't forget to make all widgets visible.
    window.show_all();
    // Handle closing of the window.
    window.connect_delete_event(|_, _| {
        // Stop the main loop.
        gtk::main_quit();
        // Let the default handler destroy the window.
        Inhibit(false)
    });
    // Run the main loop.
    gtk::main();
}

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. This crate has versions of those functions without the Send bound, which may only be called from the main thread: idle_add, timeout_add.

Panics

This and the gdk crate have some run-time safety and contract checks:

A panic in a closure will abort the process.

Crate features

Library versions

By default this crate provides only GTK+ 3.4 APIs. You can access more modern APIs by selecting one of the following features: v3_6, v3_8, v3_10, v3_12, v3_14, v3_16.

Cargo.toml example:

[dependencies.gtk]
version = "0.x.y"
features = ["v3_16"]

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.

Lgpl-docs

The Gtk-rs crates come with API docs missing because of licensing incompatibilty. You can embed those docs locally via the embed-lgpl-docs feature, e.g.

> cargo doc --features embed-lgpl-docs

Its counterpart purge-lgpl-docs removes those docs regardless of edits.

These features rewrite the crate sources so it's sufficient to enable them once. Omitting them in the following cargo invocations will not undo their effects!

Modules

prelude

Traits and essential types inteded for blanket imports.

Structs

AboutDialog

The AboutDialog offers a simple way to display information about a program like its logo, name, copyright, website and license. It is also possible to give credits to the authors, documenters, translators and artists who have worked on the program. An about dialog is typically opened when the user selects the About option from the Help menu. All parts of the dialog are optional.

AccelFlags
AccelGroup

A AccelGroup represents a group of keyboard accelerators, typically attached to a toplevel Window (with Window::add_accel_group). Usually you won’t need to create a AccelGroup directly; instead, when using UIManager, GTK+ automatically sets up the accelerators for your menus in the ui manager’s AccelGroup.

ActionBar

ActionBar is designed to present contextual actions. It is expected to be displayed below the content and expand horizontally to fill the area.

Actionable

This interface provides a convenient way of associating widgets with actions on a ApplicationWindow or Application.

Adjustment

The Adjustment object represents a value which has an associated lower and upper bound, together with step and page increments, and a page size. It is used within several GTK+ widgets, including SpinButton, Viewport, and Range (which is a base class for HScrollbar, VScrollbar, HScale, and VScale).

Alignment

[Deprecated since 3.14] The Alignment widget controls the alignment and size of its child widget. It has four settings: xscale, yscale, xalign, and yalign.

Allocation
AppChooser

AppChooser is an interface that can be implemented by widgets which allow the user to choose an application (typically for the purpose of opening a file). The main objects that implement this interface are AppChooserWidget, AppChooserDialog and AppChooserButton.

AppChooserDialog

AppChooserDialog shows a AppChooserWidget inside a Dialog.

AppChooserWidget

AppChooserWidget is a widget for selecting applications. It is the main building block for AppChooserDialog. Most applications only need to use the latter; but you can use this widget as part of a larger widget if you have special needs.

Application

Application is a class that handles many important aspects of a GTK+ application in a convenient fashion, without enforcing a one-size-fits-all application model.

ApplicationInhibitFlags
ApplicationWindow

ApplicationWindow is a Window subclass that offers some extra functionality for better integration with Application features. Notably, it can handle both the application menu as well as the menubar. See Application::set_app_menu and Application::set_menubar.

Arrow

[Deprecated since 3.14] Arrow should be used to draw simple arrows that need to point in one of the four cardinal directions (up, down, left, or right). The style of the arrow can be one of shadow in, shadow out, etched in, or etched out. Note that these directions and style types may be amended in versions of GTK+ to come.

AspectFrame

The AspectFrame is useful when you want pack a widget so that it can resize but always retains the same aspect ratio. For instance, one might be drawing a small preview of a larger image. AspectFrame derives from Frame, so it can draw a label and a frame around the child. The frame will be “shrink-wrapped” to the size of the child.

Bin

The Bin widget is a container with just one child. It is not very useful itself, but it is useful for deriving subclasses, since it provides common code needed for handling a single child widget.

Box

The Box widget organizes child widgets into a rectangular area.

Builder

A Builder is an auxiliary object that reads textual descriptions of a user interface and instantiates the described objects. To create a Builder from a user interface description, call Builder::new_from_file, Builder::new_from_resource or Builder::new_from_string.

Button

The Button widget is generally used to trigger a callback function that is called when the button is pressed. The various signals and how to use them are outlined below.

ButtonBox
Calendar

Calendar is a widget that displays a Gregorian calendar, one month at a time. It can be created with Calendar::new.

CalendarDisplayOptions
CellArea

The CellArea is an abstract class for CellLayout widgets (also referred to as "layouting widgets") to interface with an arbitrary number of GtkCellRenderers and interact with the user for a given TreeModel row.

CellAreaBox

The CellAreaBox renders cell renderers into a row or a column depending on its Orientation.

CellAreaContext

The CellAreaContext object is created by a given CellArea implementation via its CellAreaClass.create_context() virtual method and is used to store cell sizes and alignments for a series of TreeModel rows that are requested and rendered in the same context.

CellEditable

The CellEditable interface must be implemented for widgets to be usable when editing the contents of a TreeView cell.

CellLayout

CellLayout is an interface to be implemented by all objects which want to provide a TreeViewColumn like API for packing cells, setting attributes and data funcs.

CellRenderer

The CellRenderer is a base class of a set of objects used for rendering a cell to a cairo::Context. These objects are used primarily by the TreeView widget, though they aren’t tied to them in any specific way. It is worth noting that CellRenderer is not a Widget and cannot be treated as such.

CellRendererAccel

CellRendererAccel displays a keyboard accelerator (i.e. a key combination like Control + a). If the cell renderer is editable, the accelerator can be changed by simply typing the new combination.

CellRendererCombo

CellRendererCombo renders text in a cell like CellRendererText from which it is derived. But while CellRendererText offers a simple entry to edit the text, CellRendererCombo offers a ComboBox widget to edit the text. The values to display in the combo box are taken from the tree model specified in the CellRendererCombo:model property.

CellRendererPixbuf

A CellRendererPixbuf can be used to render an image in a cell. It allows to render either a given gdk_pixbuf::Pixbuf (set via the CellRendererPixbuf:pixbuf property) or a named icon (set via the CellRendererPixbuf:icon-name property).

CellRendererProgress

CellRendererProgress renders a numeric value as a progress par in a cell. Additionally, it can display a text on top of the progress bar.

CellRendererSpin

CellRendererSpin renders text in a cell like CellRendererText from which it is derived. But while CellRendererText offers a simple entry to edit the text, CellRendererSpin offers a SpinButton widget. Of course, that means that the text has to be parseable as a floating point number.

CellRendererSpinner

CellRendererSpinner renders a spinning animation in a cell, very similar to Spinner. It can often be used as an alternative to a CellRendererProgress for displaying indefinite activity, instead of actual progress.

CellRendererState
CellRendererText

A CellRendererText renders a given text in its cell, using the font, color and style information provided by its properties. The text will be ellipsized if it is too long and the CellRendererText:ellipsize property allows it.

CellRendererToggle

CellRendererToggle renders a toggle button in a cell. The button is drawn as a radio or a checkbutton, depending on the CellRendererToggle:radio property. When activated, it emits the CellRendererToggle::toggled signal.

CheckButton

A CheckButton places a discrete ToggleButton next to a widget, (usually a Label). See the section on ToggleButton widgets for more information about toggle/check buttons.

CheckMenuItem

A CheckMenuItem is a menu item that maintains the state of a boolean value in addition to a MenuItem usual role in activating application code.

Clipboard

The Clipboard object represents a clipboard of data shared between different processes or between different widgets in the same process. Each clipboard is identified by a name encoded as a gdk::Atom. (Conversion to and from strings can be done with gdk::Atom_::intern and gdk::Atom_::name.) The default clipboard corresponds to the “CLIPBOARD” atom; another commonly used clipboard is the “PRIMARY” clipboard, which, in X, traditionally contains the currently selected text.

ColorButton

The ColorButton is a button which displays the currently selected color and allows to open a color selection dialog to change the color. It is suitable widget for selecting a color in a preference dialog.

ColorChooser

ColorChooser is an interface that is implemented by widgets for choosing colors. Depending on the situation, colors may be allowed to have alpha (translucency).

ColorChooserDialog

The ColorChooserDialog widget is a dialog for choosing a color. It implements the ColorChooser interface.

ColorChooserWidget

The ColorChooserWidget widget lets the user select a color. By default, the chooser presents a predefined palette of colors, plus a small number of settable custom colors. It is also possible to select a different color with the single-color editor. To enter the single-color editing mode, use the context menu of any color of the palette, or use the '+' button to add a new custom color.

ComboBox

A ComboBox is a widget that allows the user to choose from a list of valid choices. The ComboBox displays the selected choice. When activated, the ComboBox displays a popup which allows the user to make a new choice. The style in which the selected value is displayed, and the style of the popup is determined by the current theme. It may be similar to a Windows-style combo box.

ComboBoxText

A ComboBoxText is a simple variant of ComboBox that hides the model-view complexity for simple text-only use cases.

Container

A GTK+ user interface is constructed by nesting widgets inside widgets. Container widgets are the inner nodes in the resulting tree of widgets: they contain other widgets. So, for example, you might have a Window containing a Frame containing a Label. If you wanted an image instead of a textual label inside the frame, you might replace the Label widget with a Image widget.

Continue

Continue calling the closure in the future iterations or drop it.

CssProvider

CssProvider is an object implementing the StyleProvider interface. It is able to parse CSS-like input in order to style widgets.

CssSection

Defines a part of a CSS document. Because sections are nested into one another, you can use CssSection::get_parent to get the containing region.

Dialog

Dialog boxes are a convenient way to prompt the user for a small amount of input, e.g. to display a message, ask a question, or anything else that does not require extensive effort on the user’s part.

DialogFlags
DrawingArea

The DrawingArea widget is used for creating custom user interface elements. It’s essentially a blank widget; you can draw on it. After creating a drawing area, the application may want to connect to:

Editable

The Editable interface is an interface which should be implemented by text editing widgets, such as Entry and SpinButton. It contains functions for generically manipulating an editable widget, a large number of action signals used for key bindings, and several signals that an application can connect to to modify the behavior of a widget.

Entry

The Entry widget is a single line text entry widget. A fairly large set of key bindings are supported by default. If the entered text is longer than the allocation of the widget, the widget will scroll so that the cursor position is visible.

EntryBuffer

The EntryBuffer class contains the actual text displayed in a Entry widget.

EntryCompletion

EntryCompletion is an auxiliary object to be used in conjunction with Entry to provide the completion functionality. It implements the CellLayout interface, to allow the user to add extra cells to the TreeView with completion matches.

Error

A generic error capable of representing various error domains (types).

EventBox

The EventBox widget is a subclass of Bin which also has its own window. It is useful since it allows you to catch events for widgets which do not have their own window.

EventController

EventController is a base, low-level implementation for event controllers. Those react to a series of GdkEvents, and possibly trigger actions as a consequence of those.

Expander

A Expander allows the user to hide or show its child by clicking on an expander triangle similar to the triangles used in a TreeView.

FileChooser

FileChooser is an interface that can be implemented by file selection widgets. In GTK+, the main objects that implement this interface are FileChooserWidget, FileChooserDialog, and FileChooserButton. You do not need to write an object that implements the FileChooser interface unless you are trying to adapt an existing file selector to expose a standard programming interface.

FileChooserDialog

FileChooserDialog is a dialog box suitable for use with “File/Open” or “File/Save as” commands. This widget works by putting a FileChooserWidget inside a Dialog. It exposes the FileChooser interface, so you can use all of the FileChooser functions on the file chooser dialog as well as those for Dialog.

FileChooserWidget

FileChooserWidget is a widget for choosing files. It exposes the FileChooser interface, and you should use the methods of this interface to interact with the widget.

FileFilter

A FileFilter can be used to restrict the files being shown in a FileChooser. Files can be filtered based on their name (with FileFilter::add_pattern), on their mime type (with FileFilter::add_mime_type), or by a custom filter function (with FileFilter::add_custom).

FileFilterFlags
Fixed

The Fixed widget is a container which can place child widgets at fixed positions and with fixed sizes, given in pixels. Fixed performs no automatic layout management.

FlowBox

A FlowBox positions child widgets in sequence according to its orientation.

FlowBoxChild

Feature: v3_12

FontButton

The FontButton is a button which displays the currently selected font an allows to open a font chooser dialog to change the font. It is suitable widget for selecting a font in a preference dialog.

FontChooser

FontChooser is an interface that can be implemented by widgets displaying the list of fonts. In GTK+, the main objects that implement this interface are FontChooserWidget, FontChooserDialog and FontButton.

FontChooserDialog

The FontChooserDialog widget is a dialog for selecting a font. It implements the FontChooser interface.

FontChooserWidget

The FontChooserWidget widget lists the available fonts, styles and sizes, allowing the user to select a font. It is used in the FontChooserDialog widget to provide a dialog box for selecting fonts.

Frame

The frame widget is a Bin that surrounds its child with a decorative frame and an optional label. If present, the label is drawn in a gap in the top side of the frame. The position of the label can be controlled with FrameExt::set_label_align.

GLArea

GLArea is a widget that allows drawing with OpenGL.

Gesture

Gesture is the base object for gesture recognition, although this object is quite generalized to serve as a base for multi-touch gestures, it is suitable to implement single-touch and pointer-based gestures (using the special None gdk::EventSequence value for these).

GestureDrag

GestureDrag is a Gesture implementation that recognizes drag operations. The drag operation itself can be tracked throught the GestureDrag:drag-begin, GestureDrag:drag-update and GestureDrag:drag-end signals, or the relevant coordinates be extracted through GestureDragExt::get_offset and GestureDragExt::get_start_point.

GestureLongPress

GestureLongPress is a Gesture implementation able to recognize long presses, triggering the GestureLongPress::pressed after the timeout is exceeded.

GestureMultiPress

GestureMultiPress is a Gesture implementation able to recognize multiple clicks on a nearby zone, which can be listened for through the GestureMultiPress::pressed signal. Whenever time or distance between clicks exceed the GTK+ defaults, GestureMultiPress::stopped is emitted, and the click counter is reset.

GesturePan

GesturePan is a Gesture implementation able to recognize pan gestures, those are drags that are locked to happen along one axis. The axis that a GesturePan handles is defined at construct time, and can be changed through GesturePan::set_orientation.

GestureRotate

GestureRotate is a Gesture implementation able to recognize 2-finger rotations, whenever the angle between both handled sequences changes, the GestureRotate::angle-changed signal is emitted.

GestureSingle

GestureSingle is a subclass of Gesture, optimized (although not restricted) for dealing with mouse and single-touch gestures. Under interaction, these gestures stick to the first interacting sequence, which is accessible through GestureSingleExt::get_current_sequence while the gesture is being interacted with.

GestureSwipe

GestureSwipe is a Gesture implementation able to recognize swipes, after a press/move/.../move/release sequence happens, the GestureSwipe::swipe signal will be emitted, providing the velocity and directionality of the sequence at the time it was lifted.

GestureZoom

GestureZoom is a Gesture implementation able to recognize pinch/zoom gestures, whenever the distance between both tracked sequences changes, the GestureZoom::scale-changed signal is emitted to report the scale factor.

Grid

Grid is a container which arranges its child widgets in rows and columns. It is a very similar to Table and Box, but it consistently uses Widget’s Widget:margin and Widget:expand properties instead of custom child properties, and it fully supports [height-for-width geometry management][geometry-management].

HeaderBar

HeaderBar is similar to a horizontal Box. It allows children to be placed at the start or the end. In addition, it allows a title and subtitle to be displayed. The title will be centered with respect to the width of the box, even if the children at either side take up different amounts of space. The height of the titlebar will be set to provide sufficient space for the subtitle, even if none is currently set. If a subtitle is not needed, the space reservation can be turned off with HeaderBar::set_has_subtitle.

IconView

IconView provides an alternative view on a TreeModel. It displays the model as a grid of icons with labels. Like TreeView, it allows to select one or multiple items (depending on the selection mode, see IconView::set_selection_mode). In addition to selection with the arrow keys, IconView supports rubberband selection, which is controlled by dragging the pointer.

Image

The Image widget displays an image. Various kinds of object can be displayed as an image; most typically, you would load a gdk_pixbuf::Pixbuf ("pixel buffer") from a file, and then display that. There’s a convenience function to do this, Image::new_from_file, used as follows:

ImageMenuItem

[Deprecated since 3.10] A ImageMenuItem is a menu item which has an icon next to the text label.

InfoBar

InfoBar is a widget that can be used to show messages to the user without showing a dialog. It is often temporarily shown at the top or bottom of a document. In contrast to Dialog, which has a action area at the bottom, InfoBar has an action area at the side.

Inhibit

Whether to propagate the signal to the default handler.

InputHints
JunctionSides
Label

The Label widget displays a small amount of text. As the name implies, most labels are used to label another widget such as a Button, a MenuItem, or a ComboBox.

Layout

Layout is similar to DrawingArea in that it’s a “blank slate” and doesn’t do anything but paint a blank background by default. It's different in that it supports scrolling natively (you can add it to a ScrolledWindow), and it can contain child widgets, since it’s a Container. However if you’re just going to draw, a DrawingArea is a better choice since it has lower overhead.

LevelBar

The LevelBar is a bar widget that can be used as a level indicator. Typical use cases are displaying the strength of a password, or showing the charge level of a battery.

LinkButton

A LinkButton is a Button with a hyperlink, similar to the one used by web browsers, which triggers an action when clicked. It is useful to show quick links to resources.

ListBox

A ListBox is a vertical container that contains ListBoxRow children. These rows can by dynamically sorted and filtered, and headers can be added dynamically depending on the row content. It also allows keyboard and mouse navigation and selection like a typical list.

ListBoxRow

Feature: v3_10

ListStore

The ListStore object is a list model for use with a TreeView widget. It implements the TreeModel interface, and consequentialy, can use all of the methods available there. It also implements the TreeSortable interface so it can be sorted by the view. Finally, it also implements the tree [drag and drop][gtk3-TreeView-drag-and-drop] interfaces.

Menu

A Menu is a MenuShell that implements a drop down menu consisting of a list of MenuItem objects which can be navigated and activated by the user to perform application functions.

MenuBar

The MenuBar is a subclass of MenuShell which contains one or more GtkMenuItems. The result is a standard menu bar which can hold many menu items.

MenuButton

The MenuButton widget is used to display a popup when clicked on. This popup can be provided either as a Menu, a Popover or an abstract gio::MenuModel.

MenuItem

The MenuItem widget and the derived widgets are the only valid children for menus. Their function is to correctly handle highlighting, alignment, events and submenus.

MenuShell

A MenuShell is the abstract base class used to derive the Menu and MenuBar subclasses.

MenuToolButton

A MenuToolButton is a ToolItem that contains a button and a small additional button with an arrow. When clicked, the arrow button pops up a dropdown menu.

MessageDialog

MessageDialog presents a dialog with some message text. It’s simply a convenience widget; you could construct the equivalent of MessageDialog from Dialog without too much effort, but MessageDialog saves typing.

Misc

[Deprecated since 3.14] The Misc widget is an abstract widget which is not useful itself, but is used to derive subclasses which have alignment and padding attributes.

Notebook

The Notebook widget is a Container whose children are pages that can be switched between using tab labels along one edge.

Object

The base class in the object hierarchy.

Orientable

The Orientable interface is implemented by all widgets that can be oriented horizontally or vertically. Historically, such widgets have been realized as subclasses of a common base class (e.g Box/HBox/VBox or Scale/HScale/VScale). Orientable is more flexible in that it allows the orientation to be changed at runtime, allowing the widgets to “flip”.

Overlay

Overlay is a container which contains a single main child, on top of which it can place “overlay” widgets. The position of each overlay widget is determined by its Widget:halign and Widget:valign properties. E.g. a widget with both alignments set to Align::Start will be placed at the top left corner of the main widget, whereas an overlay with halign set to Align::Center and valign set to Align::End will be placed a the bottom edge of the main widget, horizontally centered. The position can be adjusted by setting the margin properties of the child to non-zero values.

PageSetup

A PageSetup object stores the page size, orientation and margins. The idea is that you can get one of these from the page setup dialog and then pass it to the PrintOperation when printing. The benefit of splitting this out of the PrintSettings is that these affect the actual layout of the page, and thus need to be set long before user prints.

Paned

Paned has two panes, arranged either horizontally or vertically. The division between the two panes is adjustable by the user by dragging a handle.

PaperSize

PaperSize handles paper sizes. It uses the standard called PWG 5101.1-2002 PWG: Standard for Media Standardized Names to name the paper sizes (and to get the data for the page sizes). In addition to standard paper sizes, PaperSize allows to construct custom paper sizes with arbitrary dimensions.

PlacesOpenFlags
PlacesSidebar

PlacesSidebar is a widget that displays a list of frequently-used places in the file system: the user’s home directory, the user’s bookmarks, and volumes and drives. This widget is used as a sidebar in FileChooser and may be used by file managers and similar programs.

Popover

Popover is a bubble-like context window, primarily meant to provide context-dependent information or options. Popovers are attached to a widget, passed at construction time on Popover::new, or updated afterwards through PopoverExt::set_relative_to, by default they will point to the whole widget area, although this behavior can be changed through PopoverExt::set_pointing_to.

PopoverMenu

PopoverMenu is a subclass of Popover that treats its childen like menus and allows switching between them. It is meant to be used primarily together with ModelButton, but any widget can be used, such as SpinButton or Scale. In this respect, PopoverMenu is more flexible than popovers that are created from a gio::MenuModel with Popover::new_from_model.

PrintSettings

A PrintSettings object represents the settings of a print dialog in a system-independent way. The main use for this object is that once you’ve printed you can get a settings object that represents the settings the user chose, and the next time you print you can pass that object in so that the user doesn’t have to re-set all his settings.

ProgressBar

The ProgressBar is typically used to display the progress of a long running operation. It provides a visual clue that processing is underway. The ProgressBar can be used in two different modes: percentage mode and activity mode.

RadioButton

A single radio button performs the same basic function as a CheckButton, as its position in the object hierarchy reflects. It is only when multiple radio buttons are grouped together that they become a different user interface component in their own right.

Range

Range is the common base class for widgets which visualize an adjustment, e.g Scale or Scrollbar.

RecentChooser

RecentChooser is an interface that can be implemented by widgets displaying the list of recently used files. In GTK+, the main objects that implement this interface are RecentChooserWidget, RecentChooserDialog and RecentChooserMenu.

RecentChooserDialog

RecentChooserDialog is a dialog box suitable for displaying the recently used documents. This widgets works by putting a RecentChooserWidget inside a Dialog. It exposes the RecentChooserIface interface, so you can use all the RecentChooser functions on the recent chooser dialog as well as those for Dialog.

RecentChooserWidget

RecentChooserWidget is a widget suitable for selecting recently used files. It is the main building block of a RecentChooserDialog. Most applications will only need to use the latter; you can use RecentChooserWidget as part of a larger window if you have special needs.

RecentData

Meta-data to be passed to RecentManager::add_full when registering a recently used resource.

RecentFilter

A RecentFilter can be used to restrict the files being shown in a RecentChooser. Files can be filtered based on their name (with RecentFilter::add_pattern), on their mime type (with FileFilter::add_mime_type), on the application that has registered them (with RecentFilter::add_application), or by a custom filter function (with RecentFilter::add_custom).

RecentFilterFlags
RecentInfo

RecentInfo-struct contains private data only, and should be accessed using the provided API.

RecentManager

RecentManager provides a facility for adding, removing and looking up recently used files. Each recently used file is identified by its URI, and has meta-data associated to it, like the names and command lines of the applications that have registered it, the number of time each application has registered the same file, the mime type of the file and whether the file should be displayed only by the applications that have registered it.

Rectangle
RegionFlags
Requisition

A Requisition-struct represents the desired size of a widget. See [Widget’s geometry management section][geometry-management] for more information.

Revealer

The Revealer widget is a container which animates the transition of its child from invisible to visible.

Scale

A Scale is a slider control used to select a numeric value. To use it, you’ll probably want to investigate the methods on its base class, Range, in addition to the methods for Scale itself. To set the value of a scale, you would normally use RangeExt::set_value. To detect changes to the value, you would normally use the Range::value-changed signal.

ScaleButton

ScaleButton provides a button which pops up a scale widget. This kind of widget is commonly used for volume controls in multimedia applications, and GTK+ provides a VolumeButton subclass that is tailored for this use case.

Scrollable

Scrollable is an interface that is implemented by widgets with native scrolling ability.

Scrollbar

The Scrollbar widget is a horizontal or vertical scrollbar, depending on the value of the Orientable:orientation property.

ScrolledWindow

ScrolledWindow is a Bin subclass: it’s a container the accepts a single child widget. ScrolledWindow adds scrollbars to the child widget and optionally draws a beveled frame around the child widget.

SearchBar

SearchBar is a container made to have a search entry (possibly with additional connex widgets, such as drop-down menus, or buttons) built-in. The search bar would appear when a search is started through typing on the keyboard, or the application’s search mode is toggled on.

SearchEntry

SearchEntry is a subclass of Entry that has been tailored for use as a search entry.

SelectionData
Separator

Separator is a horizontal or vertical separator widget, depending on the value of the Orientable:orientation property, used to group the widgets within a window. It displays a line with a shadow to make it appear sunken into the interface.

SeparatorMenuItem

The SeparatorMenuItem is a separator used to group items within a menu. It displays a horizontal line with a shadow to make it appear sunken into the interface.

SeparatorToolItem

A SeparatorToolItem is a ToolItem that separates groups of other GtkToolItems. Depending on the theme, a SeparatorToolItem will often look like a vertical line on horizontally docked toolbars.

Settings

Settings provide a mechanism to share global settings between applications.

SizeGroup

SizeGroup provides a mechanism for grouping a number of widgets together so they all request the same amount of space. This is typically useful when you want a column of widgets to have the same size, but you can’t use a Grid widget.

Socket
SpinButton

A SpinButton is an ideal way to allow the user to set the value of some attribute. Rather than having to directly type a number into a Entry, SpinButton allows the user to click on one of two arrows to increment or decrement the displayed value. A value can still be typed in, with the bonus that it can be checked to ensure it is in a given range.

Spinner

A Spinner widget displays an icon-size spinning animation. It is often used as an alternative to a ProgressBar for displaying indefinite activity, instead of actual progress.

Stack

The Stack widget is a container which only shows one of its children at a time. In contrast to Notebook, Stack does not provide a means for users to change the visible child. Instead, the StackSwitcher widget can be used with Stack to provide this functionality.

StackSidebar

A StackSidebar enables you to quickly and easily provide a consistent "sidebar" object for your user interface.

StackSwitcher

The StackSwitcher widget acts as a controller for a Stack; it shows a row of buttons to switch between the various pages of the associated stack widget.

StateFlags
StatusIcon

[Deprecated since 3.14] The “system tray” or notification area is normally used for transient icons that indicate some special state. For example, a system tray icon might appear to tell the user that they have new mail, or have an incoming instant message, or something along those lines. The basic idea is that creating an icon in the notification area is less annoying than popping up a dialog.

Statusbar

A Statusbar is usually placed along the bottom of an application's main Window. It may provide a regular commentary of the application's status (as is usually the case in a web browser, for example), or may be used to simply output a message when the status changes, (when an upload is complete in an FTP client, for example).

StyleContext

StyleContext is an object that stores styling information affecting a widget defined by WidgetPath.

StyleProvider

StyleProvider is an interface used to provide style information to a StyleContext. See StyleContext::add_provider and StyleContext::add_provider_for_screen.

Switch

Switch is a widget that has two states: on or off. The user can control which state should be active by clicking the empty area, or by dragging the handle.

TextAttributes

Using TextAttributes directly should rarely be necessary. It’s primarily useful with TextIter::get_attributes. As with most GTK+ structs, the fields in this struct should only be read, never modified directly.

TextBuffer

You may wish to begin by reading the text widget conceptual overview which gives an overview of all the objects and data types related to the text widget and how they work together.

TextChildAnchor

A TextChildAnchor is a spot in the buffer where child widgets can be “anchored” (inserted inline, as if they were characters). The anchor can have multiple widgets anchored, to allow for multiple views.

TextIter

You may wish to begin by reading the text widget conceptual overview which gives an overview of all the objects and data types related to the text widget and how they work together.

TextMark

You may wish to begin by reading the [text widget conceptual overview][TextWidget] which gives an overview of all the objects and data types related to the text widget and how they work together.

TextSearchFlags
TextTag

You may wish to begin by reading the [text widget conceptual overview][TextWidget] which gives an overview of all the objects and data types related to the text widget and how they work together.

TextTagTable

You may wish to begin by reading the [text widget conceptual overview][TextWidget] which gives an overview of all the objects and data types related to the text widget and how they work together.

TextView

You may wish to begin by reading the [text widget conceptual overview][TextWidget] which gives an overview of all the objects and data types related to the text widget and how they work together.

ToggleButton

A ToggleButton is a Button which will remain “pressed-in” when clicked. Clicking again will cause the toggle button to return to its normal state.

ToggleToolButton

A ToggleToolButton is a ToolItem that contains a toggle button.

ToolButton

GtkToolButtons are GtkToolItems containing buttons.

ToolItem

GtkToolItems are widgets that can appear on a toolbar. To create a toolbar item that contain something else than a button, use ToolItem::new. Use ContainerExt::add to add a child widget to the tool item.

ToolItemGroup

A ToolItemGroup is used together with ToolPalette to add GtkToolItems to a palette like container with different categories and drag and drop support.

ToolPalette

A ToolPalette allows you to add GtkToolItems to a palette-like container with different categories and drag and drop support.

ToolPaletteDragTargets
ToolShell

The ToolShell interface allows container widgets to provide additional information when embedding ToolItem widgets.

Toolbar

A toolbar is created with a call to Toolbar::new.

Tooltip

Basic tooltips can be realized simply by using Widget::set_tooltip_text or Widget::set_tooltip_markup without any explicit tooltip object.

TreeIter

The TreeIter is the primary structure for accessing a TreeModel. Models are expected to put a unique integer in the stamp member, and put model-specific data in the three user_data members.

TreeModel

The TreeModel interface defines a generic tree interface for use by the TreeView widget. It is an abstract interface, and is designed to be usable with any appropriate data structure. The programmer just has to implement this interface on their own data type for it to be viewable by a TreeView widget.

TreeModelFilter

A TreeModelFilter is a tree model which wraps another tree model, and can do the following things:

TreeModelFlags
TreePath
TreeSelection

The TreeSelection object is a helper object to manage the selection for a TreeView widget. The TreeSelection object is automatically created when a new TreeView widget is created, and cannot exist independently of this widget. The primary reason the TreeSelection objects exists is for cleanliness of code and API. That is, there is no conceptual reason all these functions could not be methods on the TreeView widget instead of a separate function.

TreeSortable

TreeSortable is an interface to be implemented by tree models which support sorting. The TreeView uses the methods provided by this interface to sort the model.

TreeStore

The TreeStore object is a list model for use with a TreeView widget. It implements the TreeModel interface, and consequentialy, can use all of the methods available there. It also implements the TreeSortable interface so it can be sorted by the view. Finally, it also implements the tree [drag and drop][gtk3-TreeView-drag-and-drop] interfaces.

TreeView

Widget that displays any object that implements the TreeModel interface.

TreeViewColumn

The TreeViewColumn object represents a visible column in a TreeView widget. It allows to set properties of the column header, and functions as a holding pen for the cell renderers which determine how the data in the column is displayed.

TypedValue

A statically typed Value.

Value

A generic value capable of carrying various types.

Viewport

The Viewport widget acts as an adaptor class, implementing scrollability for child widgets that lack their own scrolling capabilities. Use Viewport to scroll child widgets such as Grid, Box, and so on.

VolumeButton

VolumeButton is a subclass of ScaleButton that has been tailored for use as a volume control widget with suitable icons, tooltips and accessible labels.

Widget

Widget is the base class all widgets in GTK+ derive from. It manages the widget lifecycle, states and style.

Window

A Window is a toplevel window which can contain other widgets. Windows normally have decorations that are under the control of the windowing system and allow the user to manipulate the window (resize it, move it, close it,...).

WindowGroup

A WindowGroup restricts the effect of grabs to windows in the same group, thereby making window groups almost behave like separate applications.

Enums

Align

Controls how a widget deals with extra space in a single (x or y) dimension.

ArrowType

Used to indicate the direction in which an arrow should point.

BaselinePosition

Whenever a container has some form of natural row it may align children in that row along a common typographical baseline. If the amount of verical space in the row is taller than the total requested height of the baseline-aligned children then it can use a BaselinePosition to select where to put the baseline inside the extra availible space.

BuilderError

Error codes that identify various errors that can occur while using Builder.

ButtonBoxStyle

Used to dictate the style that a ButtonBox uses to layout the buttons it contains.

ButtonsType

Prebuilt sets of buttons for the dialog. If none of these choices are appropriate, simply use ButtonsType::None then call Dialog::add_buttons.

CornerType

Specifies which corner a child widget should be placed in when packed into a ScrolledWindow. This is effectively the opposite of where the scroll bars are placed.

CssProviderError

Error codes for GTK_CSS_PROVIDER_ERROR.

CssSectionType

The different types of sections indicate parts of a CSS document as parsed by GTK’s CSS parser. They are oriented towards the CSS Grammar, but may contain extensions.

DeleteType

See also: Entry::delete-from-cursor.

DirectionType

Focus movement types.

DragResult

Gives an indication why a drag operation failed. The value can by obtained by connecting to the Widget::drag-failed signal.

EntryIconPosition

Specifies the side of the entry at which an icon is placed.

EventSequenceState

Describes the state of a gdk::EventSequence in a Gesture.

FileChooserAction

Describes whether a FileChooser is being used to open existing files or to save to a possibly new file.

FileChooserConfirmation

Used as a return value of handlers for the FileChooser::confirm-overwrite signal of a FileChooser. This value determines whether the file chooser will present the stock confirmation dialog, accept the user’s choice of a filename, or let the user choose another filename.

FileChooserError

These identify the various errors that can occur while calling FileChooser functions.

IconSize

Built-in stock icon sizes.

IconThemeError

Error codes for IconTheme operations.

IconViewDropPosition

An enum for determining where a dropped item goes.

ImageType

Describes the image data representation used by a Image. If you want to get the image from the widget, you can only get the currently-stored representation. e.g. if the Image::get_storage_type returns ImageType::Pixbuf, then you can call Image::get_pixbuf but not Image::get_stock. For empty images, you can request any storage type (call any of the "get" functions), but they will all return None values.

InputPurpose

Describes primary purpose of the input widget. This information is useful for on-screen keyboards and similar input methods to decide which keys should be presented to the user.

Justification

Used for justifying the text inside a Label widget. (See also Alignment).

LevelBarMode

Describes how LevelBar contents should be rendered. Note that this enumeration could be extended with additional modes in the future.

License

The type of license for an application.

MenuDirectionType

An enumeration representing directional movements within a menu.

MessageType

The type of message being displayed in the dialog.

MovementStep
NotebookTab
NumberUpLayout

Used to determine the layout of pages on a sheet when printing multiple pages per sheet.

Orientation

Represents the orientation of widgets and other objects which can be switched between horizontal and vertical orientation on the fly, like Toolbar or GesturePan.

PackDirection

Determines how widgets should be packed inside menubars and menuitems contained in menubars.

PackType

Represents the packing location Box children. (See: VBox, HBox, and ButtonBox).

PageOrientation

See also PrintSettings::set_orientation.

PageSet

See also gtk_print_job_set_page_set.

PanDirection

Describes the panning direction of a GesturePan

PolicyType

Determines how the size should be computed to achieve the one of the visibility mode for the scrollbars.

PositionType

Describes which edge of a widget a certain feature is positioned at, e.g. the tabs of a Notebook, the handle of a HandleBox or the label of a Scale.

PrintDuplex

See also PrintSettings::set_duplex.

PrintError

Error codes that identify various errors that can occur while using the GTK+ printing support.

PrintPages

See also gtk_print_job_set_pages

PrintQuality

See also PrintSettings::set_quality.

PropagationPhase

Describes the stage at which events are fed into a EventController.

RecentChooserError

These identify the various errors that can occur while calling RecentChooser functions.

RecentManagerError

Error codes for RecentManager operations

RecentSortType

Used to specify the sorting method to be applyed to the recently used resource list.

ReliefStyle

Indicated the relief to be drawn around a Button.

ResizeMode
ResponseType

Predefined values for use as response ids in DialogExt::add_button. All predefined values are negative, GTK+ leaves positive values for application-defined response ids.

RevealerTransitionType

These enumeration values describe the possible transitions when the child of a Revealer widget is shown or hidden.

ScrollStep
ScrollType

Scrolling types.

ScrollablePolicy

Defines the policy to be used in a scrollable widget when updating the scrolled window adjustments in a given orientation.

SelectionMode

Used to control what selections users are allowed to make.

SensitivityType

Determines how GTK+ handles the sensitivity of stepper arrows at the end of range widgets.

ShadowType

Used to change the appearance of an outline typically provided by a Frame.

SizeGroupMode

The mode of the size group determines the directions in which the size group affects the requested sizes of its component widgets.

SizeRequestMode

Specifies a preference for height-for-width or width-for-height geometry management.

SortColumn
SortType

Determines the direction of a sort.

SpinButtonUpdatePolicy

The spin button update policy determines whether the spin button displays values even if they are outside the bounds of its adjustment. See SpinButton::set_update_policy.

SpinType

The values of the SpinType enumeration are used to specify the change to make in SpinButton::spin.

StackTransitionType

These enumeration values describe the possible transitions between pages in a Stack widget.

StateType

This type indicates the current state of a widget; the state determines how the widget is drawn. The StateType enumeration is also used to identify different colors in a Style for drawing, so states can be used for subparts of a widget as well as entire widgets.

TextDirection

Reading directions for text.

TextExtendSelection

Granularity types that extend the text selection. Use the TextView::extend-selection signal to customize the selection.

TextWindowType

Used to reference the parts of TextView.

ToolbarStyle

Used to customize the appearance of a Toolbar. Note that setting the toolbar style overrides the user’s preferences for the default toolbar style. Note that if the button has only a label set and GTK_TOOLBAR_ICONS is used, the label will be visible, and vice versa.

TreeViewColumnSizing

The sizing method the column uses to determine its width. Please note that TreeViewColumnSizing::Autosize are inefficient for large views, and can make columns appear choppy.

TreeViewDropPosition

An enum for determining where a dropped row goes.

TreeViewGridLines

Used to indicate which grid lines to draw in a tree view.

Type

A GLib or GLib-based library type

Unit

See also PrintSettings::set_paper_width.

WidgetHelpType

Kinds of widget-specific help. Used by the ::show-help signal.

WindowPosition

Window placement can be influenced using this enumeration. Note that using WindowPosition::CenterAlways is almost always a bad idea. It won’t necessarily work well with all window managers or on all windowing systems.

WindowType

A Window can be one of these types. Most things you’d consider a “window” should have type WindowType::Toplevel; windows with this type are managed by the window manager and have a frame by default (call WindowExt::set_decorated to toggle the frame). Windows with type WindowType::Popup are ignored by the window manager; window manager keybindings won’t work on them, the window manager won’t decorate the window with a frame, many GTK+ features that rely on the window manager will not work (e.g. resize grips and maximization/minimization). WindowType::Popup is used to implement widgets such as Menu or tooltips that you normally don’t think of as windows per se. Nearly all windows should be WindowType::Toplevel. In particular, do not use WindowType::Popup just to turn off the window borders; use WindowExt::set_decorated for that.

WrapMode

Describes a type of line wrapping.

Constants

ACCEL_LOCKED
ACCEL_MASK
ACCEL_VISIBLE
APPLICATION_INHIBIT_IDLE
APPLICATION_INHIBIT_LOGOUT
APPLICATION_INHIBIT_SUSPEND
APPLICATION_INHIBIT_SWITCH
CALENDAR_NO_MONTH_CHANGE
CALENDAR_SHOW_DAY_NAMES
CALENDAR_SHOW_DETAILS
CALENDAR_SHOW_HEADING
CALENDAR_SHOW_WEEK_NUMBERS
CELL_RENDERER_EXPANDABLE
CELL_RENDERER_EXPANDED
CELL_RENDERER_FOCUSED
CELL_RENDERER_INSENSITIVE
CELL_RENDERER_PRELIT
CELL_RENDERER_SELECTED
CELL_RENDERER_SORTED
DIALOG_DESTROY_WITH_PARENT
DIALOG_MODAL
DIALOG_USE_HEADER_BAR
FILE_FILTER_DISPLAY_NAME
FILE_FILTER_FILENAME
FILE_FILTER_MIME_TYPE
FILE_FILTER_URI
INPUT_HINT_INHIBIT_OSK
INPUT_HINT_LOWERCASE
INPUT_HINT_NONE
INPUT_HINT_NO_SPELLCHECK
INPUT_HINT_SPELLCHECK
INPUT_HINT_UPPERCASE_CHARS
INPUT_HINT_UPPERCASE_SENTENCES
INPUT_HINT_UPPERCASE_WORDS
INPUT_HINT_WORD_COMPLETION
JUNCTION_BOTTOM
JUNCTION_CORNER_BOTTOMLEFT
JUNCTION_CORNER_BOTTOMRIGHT
JUNCTION_CORNER_TOPLEFT
JUNCTION_CORNER_TOPRIGHT
JUNCTION_LEFT
JUNCTION_NONE
JUNCTION_RIGHT
JUNCTION_TOP
PLACES_OPEN_NEW_TAB
PLACES_OPEN_NEW_WINDOW
PLACES_OPEN_NORMAL
RECENT_FILTER_AGE
RECENT_FILTER_APPLICATION
RECENT_FILTER_DISPLAY_NAME
RECENT_FILTER_GROUP
RECENT_FILTER_MIME_TYPE
RECENT_FILTER_URI
REGION_EVEN
REGION_FIRST
REGION_LAST
REGION_ODD
REGION_ONLY
REGION_SORTED
STATE_FLAG_ACTIVE
STATE_FLAG_BACKDROP
STATE_FLAG_CHECKED
STATE_FLAG_DIR_LTR
STATE_FLAG_DIR_RTL
STATE_FLAG_FOCUSED
STATE_FLAG_INCONSISTENT
STATE_FLAG_INSENSITIVE
STATE_FLAG_LINK
STATE_FLAG_NORMAL
STATE_FLAG_PRELIGHT
STATE_FLAG_SELECTED
STATE_FLAG_VISITED
STYLE_PROVIDER_PRIORITY_APPLICATION
STYLE_PROVIDER_PRIORITY_FALLBACK
STYLE_PROVIDER_PRIORITY_SETTINGS
STYLE_PROVIDER_PRIORITY_THEME
STYLE_PROVIDER_PRIORITY_USER
TEXT_SEARCH_CASE_INSENSITIVE
TEXT_SEARCH_TEXT_ONLY
TEXT_SEARCH_VISIBLE_ONLY
TOOL_PALETTE_DRAG_GROUPS
TOOL_PALETTE_DRAG_ITEMS
TREE_MODEL_ITERS_PERSIST
TREE_MODEL_LIST_ONLY

Traits

ActionableExt

Trait containing all Actionable methods.

BinExt

Trait containing all Bin methods.

BoxExt

Trait containing all Box methods.

ButtonExt

Trait containing all Button methods.

Cast

Upcasting and downcasting support.

CellAreaExt

Trait containing all CellArea methods.

CellAreaSignals
CellEditableExt

Trait containing all CellEditable methods.

CellLayoutExt

Trait containing all CellLayout methods.

CellRendererAccelSignals
CellRendererComboSignals
CellRendererExt

Trait containing all CellRenderer methods.

CellRendererSignals
CellRendererTextExt

Trait containing all CellRendererText methods.

CellRendererTextSignals
CellRendererToggleSignals
CheckButtonExt

Trait containing all CheckButton methods.

ComboBoxExt

Trait containing all ComboBox methods.

ContainerExt

Trait containing all Container methods.

DialogExt

Trait containing all Dialog methods.

EditableExt

Trait containing all Editable methods.

EditableSignals
EntryExt

Trait containing all Entry methods.

EventControllerExt

Trait containing all EventController methods.

FileChooserExt

Trait containing all FileChooser methods.

FontChooserExt

Trait containing all FontChooser methods.

FrameExt

Trait containing all Frame methods.

GestureDragExt

Trait containing all GestureDrag methods.

GestureExt

Trait containing all Gesture methods.

GestureSingleExt

Trait containing all GestureSingle methods.

IsA

Declares the "is a" relationship.

MenuItemExt

Trait containing all MenuItem methods.

MenuShellExt

Trait containing all MenuShell methods.

MiscExt

[Deprecated since 3.14] Trait containing all Misc methods.

OrientableExt

Trait containing all Orientable methods.

PopoverExt

Trait containing all Popover methods.

RangeExt

Trait containing all Range methods.

RecentChooserExt

Trait containing all RecentChooser methods.

ScaleButtonExt

Trait containing all ScaleButton methods.

ScrollableExt

Trait containing all Scrollable methods.

ScrolledWindowExt

Trait containing all ScrolledWindow methods.

SpinButtonSignals
StaticType

Types that are supported by GLib dynamic typing.

StyleProviderExt

Trait containing all StyleProvider methods.

ToValue

Converts to Value.

ToggleButtonExt

Trait containing all ToggleButton methods.

ToolButtonExt

Trait containing all ToolButton methods.

ToolItemExt

Trait containing all ToolItem methods.

ToolShellExt

Trait containing all ToolShell methods.

TreeModelExt

Trait containing all TreeModel methods.

TreeSortableExt

Trait containing all TreeSortable methods.

TreeViewSignals
WidgetExt

Trait containing all Widget methods.

WindowExt

Trait containing all Window methods.

Functions

check_version
events_pending
get_binary_age
get_interface_age
get_major_version
get_micro_version
get_minor_version
idle_add

Adds a closure to be called by the default main loop when it's idle.

init

Tries to initialize GTK+.

is_initialized

Returns true if GTK has been initialized.

is_initialized_main_thread

Returns true if GTK has been initialized and this is the main thread.

main
main_iteration
main_iteration_do
main_level
main_quit
set_initialized

Informs this crate that GTK has been initialized and the current thread is the main one.

timeout_add

Adds a closure to be called by the default main loop at regular intervals with millisecond granularity.

timeout_add_seconds

Adds a closure to be called by the default main loop at regular intervals with second granularity.