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
GtkInfoBar
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
info_bar_ptr
Default implementationTyped pointer to the underlying
GtkInfoBar
instance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkInfoBar
instance.Declaration
Swift
var info_bar_ptr: UnsafeMutablePointer<GtkInfoBar>! { get }
-
Required Initialiser for types conforming to
InfoBarProtocol
Declaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:
Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
InfoBarPropertyName
source 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 : ObjectProtocol
Parameters
source_property
the source property to bind
target
the target object to bind to
target_property
the target property to bind to
flags
the flags to pass to the
Binding
transform_from
ValueTransformer
to use for forward transformationtransform_to
ValueTransformer
to use for backwards transformationReturn Value
binding reference or
nil
in case of an error -
get(property:
Extension method) Get the value of a InfoBar property
Declaration
Swift
@inlinable func get(property: InfoBarPropertyName) -> GLibObject.Value
Parameters
property
the 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
property
the 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
InfoBarSignalName
signalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: InfoBarSignalName, flags f: ConnectFlags = ConnectFlags(0), handler h: @escaping SignalHandler) -> Int
Parameters
signal
The signal to connect
flags
The connection flags to use
data
A pointer to user data to provide to the callback
destroyData
A
GClosureNotify
C function to destroy the data pointed to byuserData
handler
The 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
InfoBarSignalName
signalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: InfoBarSignalName, flags f: ConnectFlags = ConnectFlags(0), data userData: gpointer!, destroyData destructor: GClosureNotify? = nil, signalHandler h: @escaping GCallback) -> Int
Parameters
signal
The signal to connect
flags
The connection flags to use
data
A pointer to user data to provide to the callback
destroyData
A
GClosureNotify
C function to destroy the data pointed to byuserData
signalHandler
The 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
close
signal 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 underlyingclose
signalDeclaration
Swift
@discardableResult @inlinable func onClose(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: InfoBarRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
handler
The signal handler to call Run the given callback whenever the
close
signal is emitted -
closeSignal
Extension methodTyped
close
signal 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_id
depends on which action widget was clicked.Note
This represents the underlyingresponse
signalDeclaration
Swift
@discardableResult @inlinable func onResponse(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: InfoBarRef, _ responseID: Int) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
responseID
the response ID
handler
The signal handler to call Run the given callback whenever the
response
signal is emitted -
responseSignal
Extension methodTyped
response
signal 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 innotify
being 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-type
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyMessageType(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: InfoBarRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyMessageType
signal is emitted -
notifyMessageTypeSignal
Extension methodTyped
notify::message-type
signal 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 innotify
being 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::revealed
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyRevealed(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: InfoBarRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyRevealed
signal is emitted -
notifyRevealedSignal
Extension methodTyped
notify::revealed
signal 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 innotify
being 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-button
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyShowCloseButton(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: InfoBarRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyShowCloseButton
signal is emitted -
notifyShowCloseButtonSignal
Extension methodTyped
notify::show-close-button
signal 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::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 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_bar
to 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_bar
to show up with a slide-in transition.Note that this property does not automatically show
info_bar
and 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)
-
actionArea
Extension methodReturns the action area of
info_bar
.Declaration
Swift
@inlinable var actionArea: BoxRef! { get }
-
contentArea
Extension methodReturns the content area of
info_bar
.Declaration
Swift
@inlinable var contentArea: BoxRef! { get }
-
messageType
Extension methodReturns the message type of the message area.
Declaration
Swift
@inlinable var messageType: GtkMessageType { get nonmutating set }
-
revealed
Extension methodUndocumented
Declaration
Swift
@inlinable var revealed: Bool { get nonmutating set }
-
showCloseButton
Extension methodReturns whether the widget will display a standard close button.
Declaration
Swift
@inlinable var showCloseButton: Bool { get nonmutating set }
-
parent
Extension methodUndocumented
Declaration
Swift
@inlinable var parent: GtkBox { get }