Struct gtk4::InfoBar[][src]

pub struct InfoBar(_);
Expand description

InfoBar can be show messages to the user without a dialog.

An example GtkInfoBar

It is often temporarily shown at the top or bottom of a document. In contrast to Dialog, which has an action area at the bottom, InfoBar has an action area at the side.

The API of InfoBar is very similar to Dialog, allowing you to add buttons to the action area with add_button() or with_buttons(). The sensitivity of action widgets can be controlled with set_response_sensitive().

To add widgets to the main content area of a InfoBar, use add_child().

Similar to MessageDialog, the contents of a InfoBar can by classified as error message, warning, informational message, etc, by using set_message_type(). GTK may use the message type to determine how the message is displayed.

A simple example for using a InfoBar: ⚠️ The following code is in 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

The InfoBar implementation of the Buildable interface exposes the content area and action area as internal children with the names “content_area” and “action_area”.

InfoBar 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

InfoBar 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.

Implements

WidgetExt, glib::ObjectExt, AccessibleExt, BuildableExt, ConstraintTargetExt, WidgetExtManual, AccessibleExtManual

Implementations

Creates a new InfoBar object.

Returns

a new InfoBar object

Creates a new builder-pattern struct instance to construct InfoBar objects.

This method returns an instance of InfoBarBuilder which can be used to create InfoBar objects.

Add an activatable widget to the action area of a InfoBar.

This also connects a signal handler that will emit the signal::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.

child

an activatable widget

response_id

response ID for child

Adds a button with the given text.

Clicking the button will emit the signal::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.

button_text

text of button

response_id

response ID for the button

Returns

the Button widget that was added

Adds a widget to the content area of the info bar.

widget

the child to be added

Returns the message type of the message area.

Returns

the message type of the message area.

Returns whether the info bar is currently revealed.

Returns

the current value of the property::InfoBar::revealed property

Returns whether the widget will display a standard close button.

Returns

true if the widget displays standard close button

Removes a widget from the action area of self.

The widget must have been put there by a call to add_action_widget() or add_button().

widget

an action widget to remove

Removes a widget from the content area of the info bar.

widget

a child that has been added to the content area

Emits the “response” signal with the given response_id.

response_id

a 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 self to be added to a widget hierarchy.

response_id

a response ID

Sets the message type of the message area.

GTK uses this type to determine how the message is displayed.

message_type

a MessageType

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.

response_id

a response ID

setting

TRUE for sensitive

Sets whether the InfoBar is revealed.

Changing this will make self reveal or conceal itself via a sliding transition.

Note: this does not show or hide self in the property::Widget::visible sense, so revealing has no effect if property::Widget::visible is false.

revealed

The new value of the property

If true, a standard close button is shown.

When clicked it emits the response ResponseType::Close.

setting

true to include a close button

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.

Emitted when an action widget is clicked.

The signal is also emitted when the application programmer calls response(). The response_id depends on which action widget was clicked.

response_id

the response ID

Creates a new InfoBar with buttons.

Button text/response ID pairs should be listed, with a None pointer ending the list. A response ID can be any positive number, or one of the values in the ResponseType enumeration. If the user clicks one of these dialog buttons, GtkInfoBar will emit the signal::InfoBar::response signal with the corresponding response ID.

first_button_text

ext to go in first button, or None

Returns

a new InfoBar

Adds multiple buttons.

This is the same as calling add_button() repeatedly. The variable argument list should be None-terminated as with with_buttons(). Each button must have both text and response ID.

first_button_text

button text

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Returns the type identifier of Self.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Upcasts an object to a superclass or interface T. Read more

Upcasts an object to a reference of its superclass or interface T. Read more

Tries to downcast to a subclass or interface implementor T. Read more

Tries to downcast to a reference of its subclass or interface implementor T. Read more

Tries to cast to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while downcast and upcast will do many checks at compile-time already. Read more

Tries to cast to reference to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while downcast and upcast will do many checks at compile-time already. Read more

Casts to T unconditionally. Read more

Casts to &T unconditionally. Read more

Performs the conversion.

Performs the conversion.

Returns true if the object is an instance of (can be cast to) T.

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Same as connect but takes a SignalId instead of a signal name.

Same as connect_local but takes a SignalId instead of a signal name.

Same as connect_unsafe but takes a SignalId instead of a signal name.

Emit signal by signal id.

Same as emit but takes Value for the arguments.

Emit signal by its name.

Same as emit_by_name but takes Value for the arguments.

Emit signal with details by signal id.

Same as emit_with_details but takes Value for the arguments.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Returns a SendValue clone of self.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.