Description
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:
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.
Functions
gtk_info_bar_new ()
GtkWidget *
gtk_info_bar_new (void);
Creates a new GtkInfoBar object.
Since: 2.18
gtk_info_bar_new_with_buttons ()
GtkWidget *
gtk_info_bar_new_with_buttons (const gchar *first_button_text,
...);
Creates a new GtkInfoBar with buttons. Button text/response ID
pairs should be listed, with a NULL pointer ending the list.
Button text can be either a stock ID such as GTK_STOCK_OK, or
some arbitrary text. 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 “response” signal with the corresponding response ID.
gtk_info_bar_add_action_widget ()
void
gtk_info_bar_add_action_widget (GtkInfoBar *info_bar,
GtkWidget *child,
gint response_id);
Add an activatable widget to the action area of a GtkInfoBar,
connecting a signal handler that will emit the “response”
signal on the message area when the widget is activated. The widget
is appended to the end of the message areas action area.
Since: 2.18
gtk_info_bar_add_button ()
GtkWidget *
gtk_info_bar_add_button (GtkInfoBar *info_bar,
const gchar *button_text,
gint response_id);
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.
Returns
the GtkButton widget
that was added.
[transfer none][type Gtk.Button]
Since: 2.18
gtk_info_bar_set_response_sensitive ()
void
gtk_info_bar_set_response_sensitive (GtkInfoBar *info_bar,
gint response_id,
gboolean setting);
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.
Since: 2.18
gtk_info_bar_set_default_response ()
void
gtk_info_bar_set_default_response (GtkInfoBar *info_bar,
gint 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.
Since: 2.18
gtk_info_bar_response ()
void
gtk_info_bar_response (GtkInfoBar *info_bar,
gint response_id);
Emits the “response” signal with the given response_id
.
Since: 2.18
gtk_info_bar_set_message_type ()
void
gtk_info_bar_set_message_type (GtkInfoBar *info_bar,
GtkMessageType message_type);
Sets the message type of the message area.
GTK+ uses this type to determine how the message is displayed.
Since: 2.18
gtk_info_bar_get_message_type ()
GtkMessageType
gtk_info_bar_get_message_type (GtkInfoBar *info_bar);
Returns the message type of the message area.
Returns
the message type of the message area.
Since: 2.18
gtk_info_bar_get_action_area ()
GtkWidget *
gtk_info_bar_get_action_area (GtkInfoBar *info_bar);
Returns the action area of info_bar
.
Returns
the action area.
[type Gtk.Box][transfer none]
Since: 2.18
gtk_info_bar_get_content_area ()
GtkWidget *
gtk_info_bar_get_content_area (GtkInfoBar *info_bar);
Returns the content area of info_bar
.
Returns
the content area.
[type Gtk.Box][transfer none]
Since: 2.18
gtk_info_bar_get_show_close_button ()
gboolean
gtk_info_bar_get_show_close_button (GtkInfoBar *info_bar);
Returns whether the widget will display a standard close button.
Returns
TRUE if the widget displays standard close button
Since: 3.10
gtk_info_bar_set_show_close_button ()
void
gtk_info_bar_set_show_close_button (GtkInfoBar *info_bar,
gboolean setting);
If true, a standard close button is shown. When clicked it emits
the response GTK_RESPONSE_CLOSE.
Since: 3.10
gtk_info_bar_get_revealed ()
gboolean
gtk_info_bar_get_revealed (GtkInfoBar *info_bar);
Returns
the current value of the GtkInfoBar:revealed property.
Since: 3.22.29
gtk_info_bar_set_revealed ()
void
gtk_info_bar_set_revealed (GtkInfoBar *info_bar,
gboolean revealed);
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.
Since: 3.22.29
Property Details
The “message-type” property
“message-type” GtkMessageType
The type of the message.
The type may be used to determine the appearance of the info bar.
Owner: GtkInfoBar
Flags: Read / Write / Construct
Default value: GTK_MESSAGE_INFO
Since: 2.18
The “revealed” property
“revealed” gboolean
Controls whether the action bar shows its contents or not.
Owner: GtkInfoBar
Flags: Read / Write
Default value: TRUE
The “show-close-button” property
“show-close-button” gboolean
Whether to include a standard close button.
Owner: GtkInfoBar
Flags: Read / Write / Construct
Default value: FALSE
Since: 3.10
Style Property Details
The “action-area-border” style property
“action-area-border” gint
Width of the border around the action area of the info bar.
Owner: GtkInfoBar
Flags: Read
Allowed values: >= 0
Default value: 5
Since: 2.18
The “button-spacing” style property
“button-spacing” gint
Spacing between buttons in the action area of the info bar.
GtkInfoBar:button-spacing has been deprecated since version 3.6 and should not be used in newly-written code.
Use gtk_box_set_spacing()
Owner: GtkInfoBar
Flags: Read
Allowed values: >= 0
Default value: 6
Since: 2.18
The “content-area-border” style property
“content-area-border” gint
The width of the border around the content
content area of the info bar.
Owner: GtkInfoBar
Flags: Read
Allowed values: >= 0
Default value: 8
Since: 2.18
The “content-area-spacing” style property
“content-area-spacing” gint
The default spacing used between elements of the
content area of the info bar.
GtkInfoBar:content-area-spacing has been deprecated since version 3.6 and should not be used in newly-written code.
Use gtk_box_set_spacing()
Owner: GtkInfoBar
Flags: Read
Allowed values: >= 0
Default value: 16
Since: 2.18
Signal Details
The “close” signal
void
user_function (GtkInfoBar *infobar,
gpointer user_data)
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.
Flags: Action
Since: 2.18
The “response” signal
void
user_function (GtkInfoBar *info_bar,
gint response_id,
gpointer user_data)
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.
Flags: Run Last
Since: 2.18