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.

  • 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

    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 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 or the application programmer calls gtk_dialog_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, connecting a signal handler that will emit the GtkInfoBar::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 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 method

    Returns the action area of info_bar.

    Declaration

    Swift

    @inlinable
    func getActionArea() -> BoxRef!
  • getContentArea() Extension method

    Returns the content area of info_bar.

    Declaration

    Swift

    @inlinable
    func getContentArea() -> BoxRef!
  • getMessageType() Extension method

    Returns the message type of the message area.

    Declaration

    Swift

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

    Undocumented

    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
  • 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)
  • 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 cause info_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 method

    Returns the action area of info_bar.

    Declaration

    Swift

    @inlinable
    var actionArea: BoxRef! { get }
  • contentArea Extension method

    Returns the content area of info_bar.

    Declaration

    Swift

    @inlinable
    var contentArea: BoxRef! { get }
  • messageType Extension method

    Returns the message type of the message area.

    Declaration

    Swift

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

    Undocumented

    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 }
  • parent Extension method

    Undocumented

    Declaration

    Swift

    @inlinable
    var parent: GtkBox { get }