ButtonRef
public struct ButtonRef : ButtonProtocol, GWeakCapturing
The GtkButton 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.
The GtkButton widget can hold any valid child widget. That is, it can hold
almost any other standard GtkWidget. The most commonly used child is the
GtkLabel.
CSS nodes
GtkButton has a single CSS node with name button. The node will get the style classes .image-button or .text-button, if the content is just an image or label, respectively. It may also receive the .flat style class.
Other style classes that are commonly used with GtkButton include .suggested-action and .destructive-action. In special cases, buttons can be made round by adding the .circular style class.
Button-like widgets like GtkToggleButton, GtkMenuButton, GtkVolumeButton,
GtkLockButton, GtkColorButton, GtkFontButton or GtkFileChooserButton use
style classes such as .toggle, .popup, .scale, .lock, .color, .font, .file
to differentiate themselves from a plain GtkButton.
The ButtonRef type acts as a lightweight Swift reference to an underlying GtkButton instance.
It exposes methods that can operate on this data type through ButtonProtocol conformance.
Use ButtonRef only as an unowned reference to an existing GtkButton instance.
-
Untyped pointer to the underlying `GtkButton` instance.For type-safe access, use the generated, typed pointer
button_ptrproperty instead.Declaration
Swift
public let ptr: UnsafeMutableRawPointer!
-
Designated initialiser from the underlying
Cdata typeDeclaration
Swift
@inlinable init(_ p: UnsafeMutablePointer<GtkButton>) -
Designated initialiser from a constant pointer to the underlying
Cdata typeDeclaration
Swift
@inlinable init(_ p: UnsafePointer<GtkButton>) -
Conditional initialiser from an optional pointer to the underlying
Cdata typeDeclaration
Swift
@inlinable init!(_ maybePointer: UnsafeMutablePointer<GtkButton>?) -
Conditional initialiser from an optional, non-mutable pointer to the underlying
Cdata typeDeclaration
Swift
@inlinable init!(_ maybePointer: UnsafePointer<GtkButton>?) -
Conditional initialiser from an optional
gpointerDeclaration
Swift
@inlinable init!(gpointer g: gpointer?) -
Conditional initialiser from an optional, non-mutable
gconstpointerDeclaration
Swift
@inlinable init!(gconstpointer g: gconstpointer?) -
Reference intialiser for a related type that implements
ButtonProtocolDeclaration
Swift
@inlinable init<T>(_ other: T) where T : ButtonProtocol -
This factory is syntactic sugar for setting weak pointers wrapped in
GWeak<T>Declaration
Swift
@inlinable static func unowned<T>(_ other: T) -> ButtonRef where T : ButtonProtocol -
Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ButtonProtocol.Declaration
Swift
@inlinable init<T>(cPointer: UnsafeMutablePointer<T>) -
Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ButtonProtocol.Declaration
Swift
@inlinable init<T>(constPointer: UnsafePointer<T>) -
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ButtonProtocol.Declaration
Swift
@inlinable init(mutating raw: UnsafeRawPointer) -
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ButtonProtocol.Declaration
Swift
@inlinable init(raw: UnsafeMutableRawPointer) -
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ButtonProtocol.Declaration
Swift
@inlinable init(opaquePointer: OpaquePointer) -
Creates a new `GtkButton` widget. To add a child widget to the button,use
gtk_container_add().Declaration
Swift
@inlinable init() -
Creates a new button containing an icon from the current icon theme.
If the icon name isn’t known, a “broken image” icon will be displayed instead. If the current icon theme is changed, the icon will be updated appropriately.
This function is a convenience wrapper around
gtk_button_new()andgtk_button_set_image().Declaration
Swift
@inlinable init(iconName: UnsafePointer<gchar>? = nil, size: GtkIconSize) -
Creates a new
GtkButtoncontaining the image and text from a stock item. Some stock ids have preprocessor macros likeGTK_STOCK_OKandGTK_STOCK_APPLY.If
stock_idis unknown, then it will be treated as a mnemonic label (as forgtk_button_new_with_mnemonic()).new_from_stock is deprecated: Stock items are deprecated. Use gtk_button_new_with_label() instead.
Declaration
Swift
@available(*, deprecated) @inlinable init(stock stockID: UnsafePointer<gchar>!) -
Creates a
GtkButtonwidget with aGtkLabelchild containing the given text.Declaration
Swift
@inlinable init(label: UnsafePointer<gchar>!) -
Creates a new
GtkButtoncontaining a label. If characters inlabelare preceded by an underscore, they are underlined. If you need a literal underscore character in a label, use “__” (two underscores). The first underlined character represents a keyboard accelerator called a mnemonic. Pressing Alt and that key activates the button.Declaration
Swift
@inlinable init(mnemonic label: UnsafePointer<gchar>!) -
Creates a new button containing an icon from the current icon theme.
If the icon name isn’t known, a “broken image” icon will be displayed instead. If the current icon theme is changed, the icon will be updated appropriately.
This function is a convenience wrapper around
gtk_button_new()andgtk_button_set_image().Declaration
Swift
@inlinable static func newFrom(iconName: UnsafePointer<gchar>? = nil, size: GtkIconSize) -> WidgetRef! -
Creates a new
GtkButtoncontaining the image and text from a stock item. Some stock ids have preprocessor macros likeGTK_STOCK_OKandGTK_STOCK_APPLY.If
stock_idis unknown, then it will be treated as a mnemonic label (as forgtk_button_new_with_mnemonic()).new_from_stock is deprecated: Stock items are deprecated. Use gtk_button_new_with_label() instead.
Declaration
Swift
@available(*, deprecated) @inlinable static func newFrom(stock stockID: UnsafePointer<gchar>!) -> WidgetRef! -
Creates a
GtkButtonwidget with aGtkLabelchild containing the given text.Declaration
Swift
@inlinable static func newWith(label: UnsafePointer<gchar>!) -> WidgetRef! -
Creates a new
GtkButtoncontaining a label. If characters inlabelare preceded by an underscore, they are underlined. If you need a literal underscore character in a label, use “__” (two underscores). The first underlined character represents a keyboard accelerator called a mnemonic. Pressing Alt and that key activates the button.Declaration
Swift
@inlinable static func newWith(mnemonic label: UnsafePointer<gchar>!) -> WidgetRef!
View on GitHub
Install in Dash
ButtonRef Structure Reference