InfoBarProtocol
public protocol InfoBarProtocol : BoxProtocol
GtkInfoBar 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 GtkDialog, which
has a 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 gtk_info_bar_add_button() or
gtk_info_bar_new_with_buttons(). The sensitivity of action widgets
can be controlled with gtk_info_bar_set_response_sensitive().
To add widgets to the main content area of a GtkInfoBar, use
gtk_info_bar_get_content_area() and add your widgets to the container.
Similar to GtkMessageDialog, the contents of a GtkInfoBar can by
classified as error message, warning, informational message, etc,
by using gtk_info_bar_set_message_type(). GTK+ may use the message type
to determine how the message is displayed.
A simple example for using a GtkInfoBar:
(C Language Example):
GtkWidget *widget, *message_label, *content_area;
GtkWidget *grid;
GtkInfoBar *bar;
// set up info bar
widget = gtk_info_bar_new ();
bar = GTK_INFO_BAR (widget);
grid = gtk_grid_new ();
gtk_widget_set_no_show_all (widget, TRUE);
message_label = gtk_label_new ("");
content_area = gtk_info_bar_get_content_area (bar);
gtk_container_add (GTK_CONTAINER (content_area),
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
The GtkInfoBar implementation of the GtkBuildable interface exposes the content area and action area as internal children with the names “content_area” and “action_area”.
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).
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.
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: ) The
closesignal is a keybinding signal which gets emitted when the user uses a keybinding to dismiss the info bar.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 or the application programmer calls
gtk_dialog_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, connecting a signal handler that will emit theGtkInfoBar::responsesignal 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 and sets things up so that clicking the button will emit the “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<gchar>!, responseID: Int) -> ButtonRef! -
getActionArea()Extension methodReturns the action area of
info_bar.Declaration
Swift
@inlinable func getActionArea() -> BoxRef! -
getContentArea()Extension methodReturns the content area of
info_bar.Declaration
Swift
@inlinable func getContentArea() -> BoxRef! -
getMessageType()Extension methodReturns the message type of the message area.
Declaration
Swift
@inlinable func getMessageType() -> GtkMessageType -
getRevealed()Extension methodUndocumented
Declaration
Swift
@inlinable func getRevealed() -> Bool -
getShowCloseButton()Extension methodReturns whether the widget will display a standard close button.
Declaration
Swift
@inlinable func getShowCloseButton() -> Bool -
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: ) Calls gtk_widget_set_sensitive (widget, setting) for each widget in the info bars’s action area with the given response_id. A convenient way to sensitize/desensitize dialog buttons.
Declaration
Swift
@inlinable func setResponseSensitive(responseID: Int, setting: Bool) -
set(revealed:Extension method) Sets the GtkInfoBar:revealed property to
revealed. This will causeinfo_barto show up with a slide-in transition.Note that this property does not automatically show
info_barand thus won’t have any effect if it is invisible.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) -
actionAreaExtension methodReturns the action area of
info_bar.Declaration
Swift
@inlinable var actionArea: BoxRef! { get } -
contentAreaExtension methodReturns the content area of
info_bar.Declaration
Swift
@inlinable var contentArea: BoxRef! { get } -
messageTypeExtension methodReturns the message type of the message area.
Declaration
Swift
@inlinable var messageType: GtkMessageType { get nonmutating set } -
revealedExtension methodUndocumented
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 } -
parentExtension methodUndocumented
Declaration
Swift
@inlinable var parent: GtkBox { get }
View on GitHub
Install in Dash
InfoBarProtocol Protocol Reference