Class InfoBar

All Implemented Interfaces:
PointerInterface

public class InfoBar extends Widget
`GtkInfoBar` can be show messages to the user without a dialog.

![An example GtkInfoBar](info-bar.png)

It is often temporarily shown at the top or bottom of a document.
In contrast to [class@Gtk.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 [method@Gtk.InfoBar.add_button]
or [ctor@Gtk.InfoBar.new_with_buttons]. The sensitivity of action widgets
can be controlled with [method@Gtk.InfoBar.set_response_sensitive].

To add widgets to the main content area of a `GtkInfoBar`, use
[method@Gtk.InfoBar.add_child].

Similar to [class@Gtk.MessageDialog], the contents of a `GtkInfoBar`
can by classified as error message, warning, informational message, etc,
by using [method@Gtk.InfoBar.set_message_type]. GTK may use the message
type to determine how the message is displayed.

A simple example for using a `GtkInfoBar`:
```c
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.

https://docs.gtk.org/gtk4/class.InfoBar.html

  • Field Details

  • Constructor Details

    • InfoBar

      public InfoBar(PointerContainer pointer)
    • InfoBar

      public InfoBar()
      Creates a new `GtkInfoBar` object.
  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • newWithButtonsInfoBar

      public static InfoBar newWithButtonsInfoBar(@Nullable Str first_button_text, Object... _elipse)
      Creates a new `GtkInfoBar` with buttons.

      Button text/response ID pairs should be listed, with a %NULL pointer
      ending the list. A response ID can be any positive number,
      or one of the values in the `GtkResponseType` enumeration. If the
      user clicks one of these dialog buttons, GtkInfoBar will emit
      the [signal@Gtk.InfoBar::response] signal with the corresponding
      response ID.
      Parameters:
      first_button_text - ext to go in first button
      _elipse - response ID for first button, then additional buttons, ending with %NULL
      Returns:
      a new `GtkInfoBar`
    • newWithButtonsInfoBar

      public static InfoBar newWithButtonsInfoBar(String first_button_text, Object... _elipse)
      Creates a new `GtkInfoBar` with buttons.

      Button text/response ID pairs should be listed, with a %NULL pointer
      ending the list. A response ID can be any positive number,
      or one of the values in the `GtkResponseType` enumeration. If the
      user clicks one of these dialog buttons, GtkInfoBar will emit
      the [signal@Gtk.InfoBar::response] signal with the corresponding
      response ID.
      Parameters:
      first_button_text - ext to go in first button
      _elipse - response ID for first button, then additional buttons, ending with %NULL
      Returns:
      a new `GtkInfoBar`
    • addActionWidget

      public void addActionWidget(@Nonnull Widget child, int response_id)
      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.
      Parameters:
      child - an activatable widget
      response_id - response ID for @child
    • addButton

      public Button addButton(@Nonnull Str button_text, int response_id)
      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.
      Parameters:
      button_text - text of button
      response_id - response ID for the button
      Returns:
      the `GtkButton` widget that was added
    • addButton

      public Button addButton(String button_text, int response_id)
      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.
      Parameters:
      button_text - text of button
      response_id - response ID for the button
      Returns:
      the `GtkButton` widget that was added
    • addButtons

      public void addButtons(@Nonnull Str first_button_text, Object... _elipse)
      Adds multiple buttons.

      This is the same as calling [method@Gtk.InfoBar.add_button]
      repeatedly. The variable argument list should be %NULL-terminated
      as with [ctor@Gtk.InfoBar.new_with_buttons]. Each button must have both
      text and response ID.
      Parameters:
      first_button_text - button text
      _elipse - response ID for first button, then more text-response_id pairs, ending with %NULL
    • addButtons

      public void addButtons(String first_button_text, Object... _elipse)
      Adds multiple buttons.

      This is the same as calling [method@Gtk.InfoBar.add_button]
      repeatedly. The variable argument list should be %NULL-terminated
      as with [ctor@Gtk.InfoBar.new_with_buttons]. Each button must have both
      text and response ID.
      Parameters:
      first_button_text - button text
      _elipse - response ID for first button, then more text-response_id pairs, ending with %NULL
    • addChild

      public void addChild(@Nonnull Widget widget)
      Adds a widget to the content area of the info bar.
      Parameters:
      widget - the child to be added
    • getMessageType

      public int getMessageType()
      Returns the message type of the message area.
      Returns:
      the message type of the message area.
    • getRevealed

      public boolean getRevealed()
      Returns whether the info bar is currently revealed.
      Returns:
      the current value of the [property@Gtk.InfoBar:revealed] property
    • getShowCloseButton

      public boolean getShowCloseButton()
      Returns whether the widget will display a standard close button.
      Returns:
      %TRUE if the widget displays standard close button
    • removeActionWidget

      public void removeActionWidget(@Nonnull Widget widget)
      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 [method@Gtk.InfoBar.add_button].
      Parameters:
      widget - an action widget to remove
    • removeChild

      public void removeChild(@Nonnull Widget widget)
      Removes a widget from the content area of the info bar.
      Parameters:
      widget - a child that has been added to the content area
    • response

      public void response(int response_id)
      Emits the “response” signal with the given @response_id.
      Parameters:
      response_id - a response ID
    • setDefaultResponse

      public void setDefaultResponse(int response_id)
      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.
      Parameters:
      response_id - a response ID
    • setMessageType

      public void setMessageType(int message_type)
      Sets the message type of the message area.

      GTK uses this type to determine how the message is displayed.
      Parameters:
      message_type - a `GtkMessageType`
    • setResponseSensitive

      public void setResponseSensitive(int response_id, boolean setting)
      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.
      Parameters:
      response_id - a response ID
      setting - TRUE for sensitive
    • setRevealed

      public void setRevealed(boolean revealed)
      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
      [property@Gtk.Widget:visible] sense, so revealing has no effect
      if [property@Gtk.Widget:visible] is %FALSE.
      Parameters:
      revealed - The new value of the property
    • setShowCloseButton

      public void setShowCloseButton(boolean setting)
      If true, a standard close button is shown.

      When clicked it emits the response %GTK_RESPONSE_CLOSE.
      Parameters:
      setting - %TRUE to include a close button
    • onClose

      public SignalHandler onClose(InfoBar.OnClose signal)
      Connect to signal "close".
      See InfoBar.OnClose.onClose() for signal description.
      Field SIGNAL_ON_CLOSE contains original signal name and can be used as resource reference.
      Parameters:
      signal - callback function (lambda).
      Returns:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • onResponse

      public SignalHandler onResponse(InfoBar.OnResponse signal)
      Connect to signal "response".
      See InfoBar.OnResponse.onResponse(int) for signal description.
      Field SIGNAL_ON_RESPONSE contains original signal name and can be used as resource reference.
      Parameters:
      signal - callback function (lambda).
      Returns:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • asAccessible

      public Accessible asAccessible()
      Implements interface Accessible. Call this to get access to interface functions.
      Overrides:
      asAccessible in class Widget
      Returns:
      Accessible
    • asBuildable

      public Buildable asBuildable()
      Implements interface Buildable. Call this to get access to interface functions.
      Overrides:
      asBuildable in class Widget
      Returns:
      Buildable
    • asConstraintTarget

      public ConstraintTarget asConstraintTarget()
      Implements interface ConstraintTarget. Call this to get access to interface functions.
      Overrides:
      asConstraintTarget in class Widget
      Returns:
      ConstraintTarget
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()