Gtk.InfoBar

const Gtk = imports.gi.Gtk;

let info_bar = new Gtk.InfoBar({
    message_type: value,
});
  

Gtk.InfoBar 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 Gtk.Dialog, which has a horizontal action area at the bottom, Gtk.InfoBar has a vertical action area at the side.

The API of Gtk.InfoBar is very similar to Gtk.Dialog, allowing you to add buttons to the action area with Gtk.add_button or Gtk.new_with_buttons. The sensitivity of action widgets can be controlled with Gtk.set_response_sensitive. To add widgets to the main content area of a Gtk.InfoBar, use Gtk.get_content_area and add your widgets to the container.

Similar to Gtk.MessageDialog, the contents of a Gtk.InfoBar can by classified as error message, warning, informational message, etc, by using Gtk.set_message_type. GTK+ uses the message type to determine the background color of the message area.

<example> <title>Simple GtkInfoBar usage.</title> <programlisting> /&ast; set up info bar &ast;/ info_bar = gtk_info_bar_new (); gtk_widget_set_no_show_all (info_bar, TRUE); message_label = gtk_label_new (""); gtk_widget_show (message_label); content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar)); gtk_container_add (GTK_CONTAINER (content_area), message_label); gtk_info_bar_add_button (GTK_INFO_BAR (info_bar), GTK_STOCK_OK, GTK_RESPONSE_OK); g_signal_connect (info_bar, "response", G_CALLBACK (gtk_widget_hide), NULL); gtk_grid_attach (GTK_GRID (grid), info_bar, 0, 2, 1, 1);

/&ast; ... &ast;/

/&ast; show an error message &ast;/ gtk_label_set_text (GTK_LABEL (message_label), error_message); gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), GTK_MESSAGE_ERROR); gtk_widget_show (info_bar); </programlisting> </example>

<refsect2 id="GtkInfoBar-BUILDER-UI"> <title>GtkInfoBar as GtkBuildable</title> <para> 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". </para> <para> GtkInfoBar supports a custom &lt;action-widgets&gt; element, which can contain multiple &lt;action-widget&gt; 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). </para> </refsect2>

Hierarchy

  • GObject.Object
    • GObject.InitiallyUnowned
      • Gtk.Widget
        • Gtk.Container
          • Gtk.Box
            • Gtk.InfoBar