Class: Gtk::InfoBar
- Defined in:
- (unknown)
Overview
GtkInfoBar can be used to show messages to the user without a dialog.

It is often temporarily shown at the top or bottom of a document.
In contrast to [classGtk.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 [methodGtk.InfoBar.add_button]
or [ctorGtk.InfoBar.new_with_buttons]. The sensitivity of action widgets
can be controlled with [methodGtk.InfoBar.set_response_sensitive].
To add widgets to the main content area of a GtkInfoBar, use
[methodGtk.InfoBar.add_child].
Similar to [classGtk.MessageDialog], the contents of a GtkInfoBar
can by classified as error message, warning, informational message, etc,
by using [methodGtk.InfoBar.set_message_type]. GTK may use the message
type to determine how the message is displayed.
A simple example for using a GtkInfoBar:
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.
Instance Method Summary collapse
-
#add_action_widget(child, response_id) ⇒ nil
Add an activatable widget to the action area of a
GtkInfoBar. -
#add_button(button_text, response_id) ⇒ Gtk::Button
Adds a button with the given text.
-
#add_buttons(first_button_text, array) ⇒ nil
Adds multiple buttons.
-
#add_child(widget) ⇒ nil
Adds a widget to the content area of the info bar.
-
#default_response=(response_id) ⇒ nil
Sets the last widget in the info bar’s action area with the given response_id as the default widget for the dialog.
-
#initialize(first_button_text, array) ⇒ Gtk::Widget
constructor
Creates a new
GtkInfoBarwith buttons. -
#message_type ⇒ Gtk::MessageType
The type of the message.
-
#message_type=(message_type) ⇒ Gtk::MessageType
The type of the message.
-
#remove_action_widget(widget) ⇒ nil
Removes a widget from the action area of info_bar.
-
#remove_child(widget) ⇒ nil
Removes a widget from the content area of the info bar.
-
#response(response_id) ⇒ nil
Emits the “response” signal with the given response_id.
-
#revealed ⇒ Boolean
Returns whether the info bar is currently revealed.
-
#revealed=(revealed) ⇒ Boolean
Whether the info bar shows its contents.
-
#revealed? ⇒ Boolean
Whether the info bar shows its contents.
-
#set_response_sensitive(response_id, setting) ⇒ nil
Sets the sensitivity of action widgets for response_id.
-
#show_close_button ⇒ Boolean
Returns whether the widget will display a standard close button.
-
#show_close_button=(show_close_button) ⇒ Boolean
Whether to include a standard close button.
-
#show_close_button? ⇒ Boolean
Whether to include a standard close button.
Methods inherited from Widget
#accessible_role, #accessible_role=, #action_set_enabled, #activate, #activate_action, #activate_action_variant, #activate_default, #activate_signal, #activate_signal=, #activate_signal_from_name=, #add_binding, #add_binding_action, #add_binding_signal, #add_controller, #add_css_class, #add_mnemonic_label, #add_shortcut, #add_tick_callback, #allocate, #allocated_baseline, #allocated_height, #allocated_width, #baseline, #bind_template_callback_full, #bind_template_child_full, #can_focus, #can_focus=, #can_focus?, #can_target, #can_target=, #can_target?, #child_focus, #child_visible, #child_visible=, #clipboard, #compute_bounds, #compute_expand, #compute_point, #compute_transform, #contains, #create_pango_context, #create_pango_layout, #css_classes, #css_classes=, #css_name, #css_name=, #cursor, #cursor=, #cursor_from_name=, default_direction, default_direction=, #direction, #direction=, #display, #dispose_template, #drag_check_threshold, #error_bell, #first_child, #focus_child, #focus_child=, #focus_on_click, #focus_on_click=, #focus_on_click?, #focusable, #focusable=, #focusable?, #font_map, #font_map=, #font_options, #font_options=, #frame_clock, #get_allocation, #get_ancestor, #get_color, #get_preferred_size, #get_size, #get_size_request, #get_template_child, #grab_focus, #halign, #halign=, #has_css_class, #has_default, #has_default=, #has_default?, #has_focus, #has_focus=, #has_focus?, #has_tooltip, #has_tooltip=, #has_tooltip?, #has_visible_focus, #height, #height_request, #height_request=, #hexpand, #hexpand=, #hexpand?, #hexpand_set, #hexpand_set=, #hexpand_set?, #hide, #in_destruction, #init_template, #insert_action_group, #insert_after, #insert_before, #install_action, #install_property_action, #is_ancestor, #is_drawable, #is_focus, #is_sensitive, #is_visible, #keynav_failed, #last_child, #layout_manager, #layout_manager=, #layout_manager_type, #layout_manager_type=, #list_mnemonic_labels, #map, #mapped, #margin_bottom, #margin_bottom=, #margin_end, #margin_end=, #margin_start, #margin_start=, #margin_top, #margin_top=, #measure, #mnemonic_activate, #name, #name=, #native, #next_sibling, #observe_children, #observe_controllers, #opacity, #opacity=, #overflow, #overflow=, #pango_context, #parent, #parent=, #pick, #prev_sibling, #primary_clipboard, #query_action, #queue_allocate, #queue_draw, #queue_resize, #realize, #realized, #receives_default, #receives_default=, #receives_default?, #remove_controller, #remove_css_class, #remove_mnemonic_label, #remove_tick_callback, #request_mode, #root, #root=, #scale_factor, #scale_factor=, #sensitive, #sensitive=, #sensitive?, #set_size_request, #set_state_flags, #settings, #should_layout, #show, #size_allocate, #snapshot_child, #state_flags, #style_context, #template=, #template_from_resource=, #template_scope=, #tooltip_markup, #tooltip_markup=, #tooltip_text, #tooltip_text=, #translate_coordinates, #trigger_tooltip_query, #unmap, #unparent, #unrealize, #unset_state_flags, #valign, #valign=, #vexpand, #vexpand=, #vexpand?, #vexpand_set, #vexpand_set=, #vexpand_set?, #visible, #visible=, #visible?, #width, #width_request, #width_request=
Constructor Details
#initialize(first_button_text, array) ⇒ Gtk::Widget
Creates a new GtkInfoBar with buttons.
Button text/response ID pairs should be listed, with a nil 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 [signalGtk.InfoBar::response] signal with the corresponding
response ID.
Instance Method Details
#add_action_widget(child, response_id) ⇒ nil
Add an activatable widget to the action area of a GtkInfoBar.
This also connects a signal handler that will emit the [signalGtk.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.
#add_button(button_text, response_id) ⇒ Gtk::Button
Adds a button with the given text.
Clicking the button will emit the [signalGtk.InfoBar::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. that was added
#add_buttons(first_button_text, array) ⇒ nil
Adds multiple buttons.
This is the same as calling [methodGtk.InfoBar.add_button] repeatedly. The variable argument list should be nil-terminated as with [ctorGtk.InfoBar.new_with_buttons]. Each button must have both text and response ID.
#add_child(widget) ⇒ nil
Adds a widget to the content area of the info bar.
#default_response=(response_id) ⇒ nil
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.
#message_type ⇒ Gtk::MessageType
The type of the message.
The type may be used to determine the appearance of the info bar.
#message_type=(message_type) ⇒ Gtk::MessageType
The type of the message.
The type may be used to determine the appearance of the info bar.
#remove_action_widget(widget) ⇒ nil
Removes a widget from the action area of info_bar.
The widget must have been put there by a call to [methodGtk.InfoBar.add_action_widget] or [methodGtk.InfoBar.add_button].
#remove_child(widget) ⇒ nil
Removes a widget from the content area of the info bar.
#response(response_id) ⇒ nil
Emits the “response” signal with the given response_id.
#revealed ⇒ Boolean
Returns whether the info bar is currently revealed.
#revealed=(revealed) ⇒ Boolean
Whether the info bar shows its contents.
#revealed? ⇒ Boolean
Whether the info bar shows its contents.
#set_response_sensitive(response_id, setting) ⇒ nil
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.
#show_close_button ⇒ Boolean
Returns whether the widget will display a standard close button.
#show_close_button=(show_close_button) ⇒ Boolean
Whether to include a standard close button.
#show_close_button? ⇒ Boolean
Whether to include a standard close button.