Struct gtk4::InfoBar [−][src]
pub struct InfoBar(_);
Expand description
InfoBar
can be show messages to the user without a dialog.
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 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
Returns whether the info bar is currently revealed.
Returns
the current value of the property::InfoBar::revealed
property
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
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
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
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
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
Returns the type identifier of Self
.
Auto Trait Implementations
impl RefUnwindSafe for InfoBar
impl UnwindSafe for InfoBar
Blanket Implementations
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 true
if the object is an instance of (can be cast to) T
.
pub fn set_property<'a, N, V>(
&self,
property_name: N,
value: V
) -> Result<(), BoolError> where
N: Into<&'a str>,
V: ToValue,
pub fn set_property_from_value<'a, N>(
&self,
property_name: N,
value: &Value
) -> Result<(), BoolError> where
N: Into<&'a str>,
pub fn set_properties_from_value(
&self,
property_values: &[(&str, Value)]
) -> Result<(), BoolError>
pub fn has_property<'a, N>(&self, property_name: N, type_: Option<Type>) -> bool where
N: Into<&'a str>,
pub fn find_property<'a, N>(&self, property_name: N) -> Option<ParamSpec> where
N: Into<&'a str>,
Safety Read more
Safety Read more
Safety Read more
Safety Read more
pub fn connect<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
N: Into<&'a str>,
F: 'static + Fn(&[Value]) -> Option<Value> + Send + Sync,
Same as connect
but takes a SignalId
instead of a signal name.
pub fn connect_local<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
N: Into<&'a str>,
F: 'static + Fn(&[Value]) -> Option<Value>,
Same as connect_local
but takes a SignalId
instead of a signal name.
pub unsafe fn connect_unsafe<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
N: Into<&'a str>,
F: Fn(&[Value]) -> Option<Value>,
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.
pub fn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec) + Send + Sync,
pub fn connect_notify_local<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec),
pub unsafe fn connect_notify_unsafe<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: Fn(&T, &ParamSpec),
pub fn bind_property<'a, O, N, M>(
&'a self,
source_property: N,
target: &'a O,
target_property: M
) -> BindingBuilder<'a> where
O: ObjectType,
N: Into<&'a str>,
M: Into<&'a str>,
Returns a SendValue
clone of self
.