InfoBarProtocol
public protocol InfoBarProtocol : WidgetProtocol
GtkInfoBar can be show messages to the user without a dialog.

It is often temporarily shown at the top or bottom of a document.
In contrast to [classGtk.Dialog], which has an action area at the
bottom, GtkInfoBar has an action area at the side.
The API of GtkInfoBar is very similar to GtkDialog, allowing you
to add buttons to the action area with [methodGtk.InfoBar.add_button]
or [ctorGtk.InfoBar.new_with_buttons]. The sensitivity of action widgets
can be controlled with [methodGtk.InfoBar.set_response_sensitive].
To add widgets to the main content area of a GtkInfoBar, use
[methodGtk.InfoBar.add_child].
Similar to [classGtk.MessageDialog], the contents of a GtkInfoBar
can by classified as error message, warning, informational message, etc,
by using [methodGtk.InfoBar.set_message_type]. GTK may use the message
type to determine how the message is displayed.
A simple example for using a GtkInfoBar:
GtkWidget *message_label;
GtkWidget *widget;
GtkWidget *grid;
GtkInfoBar *bar;
// set up info bar
widget = gtk_info_bar_new ();
bar = GTK_INFO_BAR (widget);
grid = gtk_grid_new ();
message_label = gtk_label_new ("");
gtk_info_bar_add_child (bar, message_label);
gtk_info_bar_add_button (bar,
`_("_OK")`,
GTK_RESPONSE_OK);
g_signal_connect (bar,
"response",
G_CALLBACK (gtk_widget_hide),
NULL);
gtk_grid_attach (GTK_GRID (grid),
widget,
0, 2, 1, 1);
// ...
// show an error message
gtk_label_set_text (GTK_LABEL (message_label), "An error occurred!");
gtk_info_bar_set_message_type (bar, GTK_MESSAGE_ERROR);
gtk_widget_show (bar);
GtkInfoBar as GtkBuildable
GtkInfoBar supports a custom <action-widgets> element, which can contain
multiple <action-widget> elements. The “response” attribute specifies a
numeric response, and the content of the element is the id of widget
(which should be a child of the dialogs action_area).
GtkInfoBar supports adding action widgets by specifying “action” as
the “type” attribute of a <child> element. The widget will be added
either to the action area. The response id has to be associated
with the action widget using the <action-widgets> element.
CSS nodes
GtkInfoBar has a single CSS node with name infobar. The node may get
one of the style classes .info, .warning, .error or .question, depending
on the message type.
If the info bar shows a close button, that button will have the .close
style class applied.
The InfoBarProtocol protocol exposes the methods and properties of an underlying GtkInfoBar instance.
The default implementation of these can be found in the protocol extension below.
For a concrete class that implements these methods and properties, see InfoBar.
Alternatively, use InfoBarRef as a lighweight, unowned reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
GtkInfoBarinstance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get } -
info_bar_ptrDefault implementationTyped pointer to the underlying
GtkInfoBarinstance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkInfoBarinstance.Declaration
Swift
var info_bar_ptr: UnsafeMutablePointer<GtkInfoBar>! { get } -
Required Initialiser for types conforming to
InfoBarProtocolDeclaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
InfoBarPropertyNamesource property to a given target object.Declaration
Swift
@discardableResult @inlinable func bind<Q, T>(property source_property: InfoBarPropertyName, to target: T, _ target_property: Q, flags f: BindingFlags = .default, transformFrom transform_from: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }, transformTo transform_to: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }) -> BindingRef! where Q : PropertyNameProtocol, T : ObjectProtocolParameters
source_propertythe source property to bind
targetthe target object to bind to
target_propertythe target property to bind to
flagsthe flags to pass to the
Bindingtransform_fromValueTransformerto use for forward transformationtransform_toValueTransformerto use for backwards transformationReturn Value
binding reference or
nilin case of an error -
get(property:Extension method) Get the value of a InfoBar property
Declaration
Swift
@inlinable func get(property: InfoBarPropertyName) -> GLibObject.ValueParameters
propertythe property to get the value for
Return Value
the value of the named property
-
set(property:Extension methodvalue: ) Set the value of a InfoBar property. Note that this will only have an effect on properties that are writable and not construct-only!
Declaration
Swift
@inlinable func set(property: InfoBarPropertyName, value v: GLibObject.Value)Parameters
propertythe property to get the value for
Return Value
the value of the named property
-
connect(signal:Extension methodflags: handler: ) Connect a Swift signal handler to the given, typed
InfoBarSignalNamesignalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: InfoBarSignalName, flags f: ConnectFlags = ConnectFlags(0), handler h: @escaping SignalHandler) -> IntParameters
signalThe signal to connect
flagsThe connection flags to use
dataA pointer to user data to provide to the callback
destroyDataA
GClosureNotifyC function to destroy the data pointed to byuserDatahandlerThe Swift signal handler (function or callback) to invoke on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
connect(signal:Extension methodflags: data: destroyData: signalHandler: ) Connect a C signal handler to the given, typed
InfoBarSignalNamesignalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: InfoBarSignalName, flags f: ConnectFlags = ConnectFlags(0), data userData: gpointer!, destroyData destructor: GClosureNotify? = nil, signalHandler h: @escaping GCallback) -> IntParameters
signalThe signal to connect
flagsThe connection flags to use
dataA pointer to user data to provide to the callback
destroyDataA
GClosureNotifyC function to destroy the data pointed to byuserDatasignalHandlerThe C function to be called on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
onClose(flags:Extension methodhandler: ) Gets emitted when the user uses a keybinding to dismiss the info bar.
The
closesignal is a keybinding signal.The default binding for this signal is the Escape key.
Note
This represents the underlyingclosesignalDeclaration
Swift
@discardableResult @inlinable func onClose(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: InfoBarRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
handlerThe signal handler to call Run the given callback whenever the
closesignal is emitted -
closeSignalExtension methodTyped
closesignal for using theconnect(signal:)methodsDeclaration
Swift
static var closeSignal: InfoBarSignalName { get } -
onResponse(flags:Extension methodhandler: ) Emitted when an action widget is clicked.
The signal is also emitted when the application programmer calls [method
Gtk.InfoBar.response]. Theresponse_iddepends on which action widget was clicked.Note
This represents the underlyingresponsesignalDeclaration
Swift
@discardableResult @inlinable func onResponse(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: InfoBarRef, _ responseId: Int) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
responseIdthe response ID
handlerThe signal handler to call Run the given callback whenever the
responsesignal is emitted -
responseSignalExtension methodTyped
responsesignal for using theconnect(signal:)methodsDeclaration
Swift
static var responseSignal: InfoBarSignalName { get } -
onNotifyMessageType(flags:Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property(),g_object_set(), et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY, then any call tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::message-typesignalDeclaration
Swift
@discardableResult @inlinable func onNotifyMessageType(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: InfoBarRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyMessageTypesignal is emitted -
notifyMessageTypeSignalExtension methodTyped
notify::message-typesignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyMessageTypeSignal: InfoBarSignalName { get } -
onNotifyRevealed(flags:Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property(),g_object_set(), et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY, then any call tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::revealedsignalDeclaration
Swift
@discardableResult @inlinable func onNotifyRevealed(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: InfoBarRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyRevealedsignal is emitted -
notifyRevealedSignalExtension methodTyped
notify::revealedsignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyRevealedSignal: InfoBarSignalName { get } -
onNotifyShowCloseButton(flags:Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property(),g_object_set(), et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY, then any call tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::show-close-buttonsignalDeclaration
Swift
@discardableResult @inlinable func onNotifyShowCloseButton(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: InfoBarRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyShowCloseButtonsignal is emitted -
notifyShowCloseButtonSignalExtension methodTyped
notify::show-close-buttonsignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyShowCloseButtonSignal: InfoBarSignalName { get }
-
addActionWidget(child:Extension methodresponseId: ) Add an activatable widget to the action area of a
GtkInfoBar.This also connects a signal handler that will emit the [signal
Gtk.InfoBar::response] signal on the message area when the widget is activated. The widget is appended to the end of the message areas action area.Declaration
Swift
@inlinable func addActionWidget<WidgetT>(child: WidgetT, responseId: Int) where WidgetT : WidgetProtocol -
addButton(buttonText:Extension methodresponseId: ) Adds a button with the given text.
Clicking the button will emit the [signal
Gtk.InfoBar::response] signal with the given response_id. The button is appended to the end of the info bars’s action area. The button widget is returned, but usually you don’t need it.Declaration
Swift
@inlinable func addButton(buttonText: UnsafePointer<CChar>!, responseId: Int) -> ButtonRef! -
addChild(widget:Extension method) Adds a widget to the content area of the info bar.
Declaration
Swift
@inlinable func addChild<WidgetT>(widget: WidgetT) where WidgetT : WidgetProtocol -
getMessageType()Extension methodReturns the message type of the message area.
Declaration
Swift
@inlinable func getMessageType() -> GtkMessageType -
getRevealed()Extension methodReturns whether the info bar is currently revealed.
Declaration
Swift
@inlinable func getRevealed() -> Bool -
getShowCloseButton()Extension methodReturns whether the widget will display a standard close button.
Declaration
Swift
@inlinable func getShowCloseButton() -> Bool -
removeAction(widget:Extension method) Removes a widget from the action area of
info_bar.The widget must have been put there by a call to [method
Gtk.InfoBar.add_action_widget] or [methodGtk.InfoBar.add_button].Declaration
Swift
@inlinable func removeAction<WidgetT>(widget: WidgetT) where WidgetT : WidgetProtocol -
removeChild(widget:Extension method) Removes a widget from the content area of the info bar.
Declaration
Swift
@inlinable func removeChild<WidgetT>(widget: WidgetT) where WidgetT : WidgetProtocol -
response(responseId:Extension method) Emits the “response” signal with the given
response_id.Declaration
Swift
@inlinable func response(responseId: Int) -
setDefaultResponse(responseId:Extension method) Sets the last widget in the info bar’s action area with the given response_id as the default widget for the dialog.
Pressing “Enter” normally activates the default widget.
Note that this function currently requires
info_barto be added to a widget hierarchy.Declaration
Swift
@inlinable func setDefaultResponse(responseId: Int) -
set(messageType:Extension method) Sets the message type of the message area.
GTK uses this type to determine how the message is displayed.
Declaration
Swift
@inlinable func set(messageType: GtkMessageType) -
setResponseSensitive(responseId:Extension methodsetting: ) Sets the sensitivity of action widgets for
response_id.Calls
gtk_widget_set_sensitive (widget, setting)for each widget in the info bars’s action area with the givenresponse_id. A convenient way to sensitize/desensitize buttons.Declaration
Swift
@inlinable func setResponseSensitive(responseId: Int, setting: Bool) -
set(revealed:Extension method) Sets whether the
GtkInfoBaris revealed.Changing this will make
info_barreveal or conceal itself via a sliding transition.Note: this does not show or hide
info_barin the [propertyGtk.Widget:visible] sense, so revealing has no effect if [propertyGtk.Widget:visible] isfalse.Declaration
Swift
@inlinable func set(revealed: Bool) -
setShowCloseButton(setting:Extension method) If true, a standard close button is shown.
When clicked it emits the response
GTK_RESPONSE_CLOSE.Declaration
Swift
@inlinable func setShowCloseButton(setting: Bool) -
messageTypeExtension methodReturns the message type of the message area.
Declaration
Swift
@inlinable var messageType: GtkMessageType { get nonmutating set } -
revealedExtension methodWhether the info bar shows its contents.
Declaration
Swift
@inlinable var revealed: Bool { get nonmutating set } -
showCloseButtonExtension methodReturns whether the widget will display a standard close button.
Declaration
Swift
@inlinable var showCloseButton: Bool { get nonmutating set }
View on GitHub
Install in Dash
InfoBarProtocol Protocol Reference