:right-sidebar: True InfoBar =================================================================== .. currentmodule:: gi.repository.Gtk .. deprecated:: 4.10 There is no replacement in GTK for an "info bar" widget; you can use :obj:`~gi.repository.Gtk.Revealer` with a :obj:`~gi.repository.Gtk.Box` containing a :obj:`~gi.repository.Gtk.Label` and an optional :obj:`~gi.repository.Gtk.Button`, according to your application's design. .. class:: InfoBar(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gtk.Widget`, :class:`~gi.repository.GObject.InitiallyUnowned`, :class:`~gi.repository.GObject.Object` Implemented Interfaces: :class:`~gi.repository.Gtk.Accessible`, :class:`~gi.repository.Gtk.Buildable`, :class:`~gi.repository.Gtk.ConstraintTarget` ``GtkInfoBar`` can be used to show messages to the user without a dialog. .. image:: https://docs.gtk.org/gtk4/info-bar.png It is often temporarily shown at the top or bottom of a document. In contrast to :obj:`~gi.repository.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 :obj:`~gi.repository.Gtk.InfoBar.add_button` or :obj:`~gi.repository.Gtk.InfoBar.new_with_buttons`. The sensitivity of action widgets can be controlled with :obj:`~gi.repository.Gtk.InfoBar.set_response_sensitive`. To add widgets to the main content area of a ``GtkInfoBar``, use :obj:`~gi.repository.Gtk.InfoBar.add_child`. Similar to :obj:`~gi.repository.Gtk.MessageDialog`, the contents of a ``GtkInfoBar`` can by classified as error message, warning, informational message, etc, by using :obj:`~gi.repository.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``: .. code-block:: :dedent: 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 ```` element, which can contain multiple ```` 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 ```` element. The widget will be added either to the action area. The response id has to be associated with the action widget using the ```` 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. Constructors ------------ .. rst-class:: interim-class .. class:: InfoBar :no-index: .. classmethod:: new() -> ~gi.repository.Gtk.Widget Creates a new ``GtkInfoBar`` object. .. deprecated:: 4.10 Please do not use it in newly written code Methods ------- .. rst-class:: interim-class .. class:: InfoBar :no-index: .. method:: add_action_widget(child: ~gi.repository.Gtk.Widget, response_id: int) -> None Add an activatable widget to the action area of a ``GtkInfoBar``. This also connects a signal handler that will emit the :obj:`~gi.repository.Gtk.InfoBar.signals.response` signal on the message area when the widget is activated. The widget is appended to the end of the message areas action area. .. deprecated:: 4.10 Please do not use it in newly written code :param child: an activatable widget :param response_id: response ID for ``child`` .. method:: add_button(button_text: str, response_id: int) -> ~gi.repository.Gtk.Button Adds a button with the given text. Clicking the button will emit the :obj:`~gi.repository.Gtk.InfoBar.signals.response` signal with the given response_id. The button is appended to the end of the info bar's action area. The button widget is returned, but usually you don't need it. .. deprecated:: 4.10 Please do not use it in newly written code :param button_text: text of button :param response_id: response ID for the button .. method:: add_child(widget: ~gi.repository.Gtk.Widget) -> None Adds a widget to the content area of the info bar. .. deprecated:: 4.10 Please do not use it in newly written code :param widget: the child to be added .. method:: get_message_type() -> ~gi.repository.Gtk.MessageType Returns the message type of the message area. .. deprecated:: 4.10 Please do not use it in newly written code .. method:: get_revealed() -> bool Returns whether the info bar is currently revealed. .. deprecated:: 4.10 Please do not use it in newly written code .. method:: get_show_close_button() -> bool Returns whether the widget will display a standard close button. .. deprecated:: 4.10 Please do not use it in newly written code .. method:: remove_action_widget(widget: ~gi.repository.Gtk.Widget) -> None Removes a widget from the action area of ``info_bar``. The widget must have been put there by a call to :obj:`~gi.repository.Gtk.InfoBar.add_action_widget` or :obj:`~gi.repository.Gtk.InfoBar.add_button`. .. deprecated:: 4.10 Please do not use it in newly written code :param widget: an action widget to remove .. method:: remove_child(widget: ~gi.repository.Gtk.Widget) -> None Removes a widget from the content area of the info bar. .. deprecated:: 4.10 Please do not use it in newly written code :param widget: a child that has been added to the content area .. method:: response(response_id: int) -> None Emits the “response” signal with the given ``response_id``. .. deprecated:: 4.10 Please do not use it in newly written code :param response_id: a response ID .. method:: set_default_response(response_id: int) -> None 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. .. deprecated:: 4.10 Please do not use it in newly written code :param response_id: a response ID .. method:: set_message_type(message_type: ~gi.repository.Gtk.MessageType) -> None Sets the message type of the message area. GTK uses this type to determine how the message is displayed. .. deprecated:: 4.10 Please do not use it in newly written code :param message_type: a ``GtkMessageType`` .. method:: set_response_sensitive(response_id: int, setting: bool) -> None 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. .. deprecated:: 4.10 Please do not use it in newly written code :param response_id: a response ID :param setting: TRUE for sensitive .. method:: set_revealed(revealed: bool) -> None 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 :obj:`~gi.repository.Gtk.Widget.props.visible` sense, so revealing has no effect if :obj:`~gi.repository.Gtk.Widget.props.visible` is :const:`False`. .. deprecated:: 4.10 Please do not use it in newly written code :param revealed: The new value of the property .. method:: set_show_close_button(setting: bool) -> None If true, a standard close button is shown. When clicked it emits the response :const:`~gi.repository.Gtk.ResponseType.CLOSE`. .. deprecated:: 4.10 Please do not use it in newly written code :param setting: :const:`True` to include a close button Properties ---------- .. rst-class:: interim-class .. class:: InfoBar :no-index: .. attribute:: props.message_type :type: ~gi.repository.Gtk.MessageType The type of the message. The type may be used to determine the appearance of the info bar. .. attribute:: props.revealed :type: bool Whether the info bar shows its contents. .. attribute:: props.show_close_button :type: bool Whether to include a standard close button. Signals ------- .. rst-class:: interim-class .. class:: InfoBar.signals :no-index: .. method:: close() -> None 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. .. method:: response(response_id: int) -> None Emitted when an action widget is clicked. The signal is also emitted when the application programmer calls :obj:`~gi.repository.Gtk.InfoBar.response`. The ``response_id`` depends on which action widget was clicked. :param response_id: the response ID