InfoBarProtocol

public protocol InfoBarProtocol : WidgetProtocol

GtkInfoBar can be show messages to the user without a dialog.

An example GtkInfoBar

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 &lt;child&gt; element. The widget will be added either to the action area. The response id has to be associated with the action widget using the &lt;action-widgets&gt; 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.

  • ptr

    Untyped pointer to the underlying GtkInfoBar instance.

    Declaration

    Swift

    var ptr: UnsafeMutableRawPointer! { get }
  • info_bar_ptr Default implementation

    Typed 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)

InfoBar Class

  • 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 transformation

    transform_to

    ValueTransformer to use for backwards transformation

    Return 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:value:) Extension method

    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

InfoBar signals

  • Connect a Swift signal handler to the given, typed InfoBarSignalName signal

    Declaration

    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 by userData

    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 a C signal handler to the given, typed InfoBarSignalName signal

    Declaration

    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 by userData

    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:handler:) Extension method

    Gets emitted when the user uses a keybinding to dismiss the info bar.

    The close signal is a keybinding signal.

    The default binding for this signal is the Escape key.

    Note

    This represents the underlying close signal

    Declaration

    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 method

    Typed close signal for using the connect(signal:) methods

    Declaration

    Swift

    static var closeSignal: InfoBarSignalName { get }
  • onResponse(flags:handler:) Extension method

    Emitted when an action widget is clicked.

    The signal is also emitted when the application programmer calls [methodGtk.InfoBar.response]. The response_id depends on which action widget was clicked.

    Note

    This represents the underlying response signal

    Declaration

    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 method

    Typed response signal for using the connect(signal:) methods

    Declaration

    Swift

    static var responseSignal: InfoBarSignalName { get }
  • 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 to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_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 underlying notify::message-type signal

    Declaration

    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 method

    Typed notify::message-type signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyMessageTypeSignal: InfoBarSignalName { get }
  • 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 to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_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 underlying notify::revealed signal

    Declaration

    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 method

    Typed notify::revealed signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyRevealedSignal: InfoBarSignalName { get }
  • 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 to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_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 underlying notify::show-close-button signal

    Declaration

    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 method

    Typed notify::show-close-button signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyShowCloseButtonSignal: InfoBarSignalName { get }

InfoBar Class: InfoBarProtocol extension (methods and fields)

  • Add an activatable widget to the action area of a GtkInfoBar.

    This also connects a signal handler that will emit the [signalGtk.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
  • Adds a button with the given text.

    Clicking the button will emit the [signalGtk.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 method

    Returns the message type of the message area.

    Declaration

    Swift

    @inlinable
    func getMessageType() -> GtkMessageType
  • getRevealed() Extension method

    Returns whether the info bar is currently revealed.

    Declaration

    Swift

    @inlinable
    func getRevealed() -> Bool
  • getShowCloseButton() Extension method

    Returns 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 [methodGtk.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)
  • 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)
  • 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 given response_id. A convenient way to sensitize/desensitize buttons.

    Declaration

    Swift

    @inlinable
    func setResponseSensitive(responseId: Int, setting: Bool)
  • set(revealed:) Extension method

    Sets whether the GtkInfoBar is revealed.

    Changing this will make info_bar reveal or conceal itself via a sliding transition.

    Note: this does not show or hide info_bar in the [propertyGtk.Widget:visible] sense, so revealing has no effect if [propertyGtk.Widget:visible] is false.

    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)
  • messageType Extension method

    Returns the message type of the message area.

    Declaration

    Swift

    @inlinable
    var messageType: GtkMessageType { get nonmutating set }
  • revealed Extension method

    Whether the info bar shows its contents.

    Declaration

    Swift

    @inlinable
    var revealed: Bool { get nonmutating set }
  • showCloseButton Extension method

    Returns whether the widget will display a standard close button.

    Declaration

    Swift

    @inlinable
    var showCloseButton: Bool { get nonmutating set }