Struct gtk4::InfoBar

source ·
#[repr(transparent)]
pub struct InfoBar { /* private fields */ }
Expand description

There is no replacement in GTK for an “info bar” widget; you can use Revealer with a Box containing a Label and an optional Button, according to your application’s design. 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

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

InfoBar 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

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.

Deprecated since 4.10
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.

Deprecated since 4.10
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 bar’s action area. The button widget is returned, but usually you don’t need it.

Deprecated since 4.10
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.

Deprecated since 4.10
widget

the child to be added

Returns the message type of the message area.

Deprecated since 4.10
Returns

the message type of the message area.

Returns whether the info bar is currently revealed.

Deprecated since 4.10
Returns

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

Returns whether the widget will display a standard close button.

Deprecated since 4.10
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().

Deprecated since 4.10
widget

an action widget to remove

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

Deprecated since 4.10
widget

a child that has been added to the content area

Emits the “response” signal with the given @response_id.

Deprecated since 4.10
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.

Deprecated since 4.10
response_id

a response ID

Sets the message type of the message area.

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

Deprecated since 4.10
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.

Deprecated since 4.10
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.

Deprecated since 4.10
revealed

The new value of the property

If true, a standard close button is shown.

When clicked it emits the response ResponseType::Close.

Deprecated since 4.10
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.

Deprecated since 4.10
first_button_text

ext to go in first button

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.

Deprecated since 4.10
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 !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
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§

Updates an array of accessible properties. Read more
Updates an array of accessible relations. Read more
Updates an array of accessible states. Read more
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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Returns true if the object is an instance of (can be cast to) T.
Returns the type of the object.
Returns the ObjectClass of the object. Read more
Returns the class of the object.
Returns the class of the object in the given type T. Read more
Returns the interface T of the object. Read more
Sets the property property_name of the object to value value. Read more
Sets the property property_name of the object to value value. Read more
Sets multiple properties of the object at once. Read more
Sets multiple properties of the object at once. Read more
Gets the property property_name of the object and cast it to the type V. Read more
Gets the property property_name of the object. Read more
Check if the object has a property property_name of the given type_. Read more
Get the type of the property property_name of this object. Read more
Get the ParamSpec of the property property_name of this object.
Return all ParamSpec of the properties of this object.
Freeze all property notifications until the return guard object is dropped. Read more
Set arbitrary data on this object with the given key. Read more
Return previously set arbitrary data of this object with the given key. Read more
Retrieve previously set arbitrary data of this object with the given key. Read more
Set arbitrary data on this object with the given key. Read more
Return previously set arbitrary data of this object with the given key. Read more
Retrieve previously set arbitrary data of this object with the given key. Read more
Block a given signal handler. Read more
Unblock a given signal handler.
Stop emission of the currently emitted signal.
Stop emission of the currently emitted signal by the (possibly detailed) signal name.
Connect to the signal signal_name on this object. Read more
Connect to the signal signal_id on this object. Read more
Connect to the signal signal_name on this object. Read more
Connect to the signal signal_id on this object. Read more
Connect to the signal signal_name on this object. Read more
Connect to the signal signal_id on this object. Read more
Connect a closure to the signal signal_name on this object. Read more
Connect a closure to the signal signal_id on this object. Read more
Limits the lifetime of closure to the lifetime of the object. When the object’s reference count drops to zero, the closure will be invalidated. An invalidated closure will ignore any calls to invoke_with_values, or invoke when using Rust closures. Read more
Emit signal by signal id. Read more
Same as Self::emit but takes Value for the arguments.
Emit signal by its name. Read more
Emit signal by its name. Read more
Emit signal by its name with details. Read more
Emit signal by its name with details. Read more
Emit signal by signal id with details. Read more
Emit signal by signal id with details. Read more
Disconnect a previously connected signal handler.
Connect to the notify signal of the object. Read more
Connect to the notify signal of the object. Read more
Connect to the notify signal of the object. Read more
Notify that the given property has changed its value. Read more
Notify that the given property has changed its value. Read more
Downgrade this object to a weak reference.
Add a callback to be notified when the Object is disposed.
Add a callback to be notified when the Object is disposed. Read more
Bind property source_property on this object to the target_property on the target object. Read more
Returns the strong reference count of this object.
Runs the dispose mechanism of the object. Read more
Ensures that the type has been registered with the type system.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
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.