Gnome::Gtk4::InfoBar
Description
Gnome::Gtk4::InfoBar 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 Gnome::Gtk4::Dialog, which has an action area at the bottom, Gnome::Gtk4::InfoBar has an action area at the side.
The API of Gnome::Gtk4::InfoBar is very similar to Gnome::Gtk4::Dialog, allowing you to add buttons to the action area with .add-button()
or .new-with-buttons()
. The sensitivity of action widgets can be controlled with .set-response-sensitive()
.
To add widgets to the main content area of a Gnome::Gtk4::InfoBar, use .add-child()
.
Similar to Gnome::Gtk4::MessageDialog, the contents of a Gnome::Gtk4::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 Gnome::Gtk4::InfoBar:
GtkInfoBar as GtkBuildable
Gnome::Gtk4::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
).
Gnome::Gtk4::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
Gnome::Gtk4::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.
Class initialization
Note: The native version of this class is deprecated in gtk4-lib() since version 4.10
new
:native-object
Create an object using a native object from elsewhere. See also Gnome::N::TopLevelSupportClass.
multi method new ( N-Object :$native-object! )
new-infobar
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
Creates a new Gnome::Gtk4::InfoBar object.
method new-infobar ( --> Gnome::Gtk4::InfoBar \)
new-with-buttons This function is not yet available
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
Creates a new Gnome::Gtk4::InfoBar with buttons.
Button text/response ID pairs should be listed, with a undefined pointer ending the list. A response ID can be any positive number, or one of the values in the enumeration GtkResponseType defined in Gnome::Gtk4::T-dialog
enumeration. If the user clicks one of these dialog buttons, GtkInfoBar will emit the response signal with the corresponding response ID.
method new-with-buttons ( Str $first-button-text, … --> Gnome::Gtk4::InfoBar \)
$first-button-text; ext to go in first button.
…; …. Note that each argument must be specified as a type followed by its value!
Methods
add-action-widget
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
Add an activatable widget to the action area of a Gnome::Gtk4::InfoBar.
This also connects 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.
method add-action-widget ( N-Object() $child, Int() $response-id )
$child; an activatable widget.
$response-id; response ID for
$child
.
add-button
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
Adds a button with the given text.
Clicking the button will emit the 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.
method add-button ( Str $button-text, Int() $response-id --> N-Object )
$button-text; text of button.
$response-id; response ID for the button.
Return value; the Gnome::Gtk4::Button widget that was added.
add-buttons This function is not yet available
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
Adds multiple buttons.
This is the same as calling .add-button()
repeatedly. The variable argument list should be undefined-terminated as with .new-with-buttons()
. Each button must have both text and response ID.
method add-buttons ( Str $first-button-text, … )
$first-button-text; button text.
…; …. Note that each argument must be specified as a type followed by its value!
add-child
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
Adds a widget to the content area of the info bar.
method add-child ( N-Object() $widget )
$widget; the child to be added.
get-message-type
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
Returns the message type of the message area.
method get-message-type (--> GtkMessageType )
Return value; the message type of the message area..
get-revealed
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
Returns whether the info bar is currently revealed.
method get-revealed (--> Bool )
Return value; the current value of the revealed property.
get-show-close-button
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
Returns whether the widget will display a standard close button.
method get-show-close-button (--> Bool )
Return value; True
if the widget displays standard close button.
remove-action-widget
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
Removes a widget from the action area of $info-bar
.
The widget must have been put there by a call to .add-action-widget()
or .add-button()
.
method remove-action-widget ( N-Object() $widget )
$widget; an action widget to remove.
remove-child
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
Removes a widget from the content area of the info bar.
method remove-child ( N-Object() $widget )
$widget; a child that has been added to the content area.
response
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
Emits the “response” signal with the given $response-id
.
method response ( Int() $response-id )
$response-id; a response ID.
set-default-response
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
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.
method set-default-response ( Int() $response-id )
$response-id; a response ID.
set-message-type
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
Sets the message type of the message area.
GTK uses this type to determine how the message is displayed.
method set-message-type ( GtkMessageType $message-type )
$message-type; a
enumeration GtkMessageType defined in Gnome::Gtk4::T-enums
.
set-response-sensitive
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
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.
method set-response-sensitive ( Int() $response-id, Bool() $setting )
$response-id; a response ID.
$setting; TRUE for sensitive.
set-revealed
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
Sets whether the Gnome::Gtk4::InfoBar is revealed.
Changing this will make $info-bar
reveal or conceal itself via a sliding transition.
Note: this does not show or hide $info-bar
in the visible defined in Gnome::Gtk4::Widget sense, so revealing has no effect if visible defined in Gnome::Gtk4::Widget is False
.
method set-revealed ( Bool() $revealed )
$revealed; The new value of the property.
set-show-close-button
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
If true, a standard close button is shown.
When clicked it emits the response GTK_RESPONSE_CLOSE
.
method set-show-close-button ( Bool() $setting )
$setting;
True
to include a close button.
Signals
close
Gets emitted when the user uses a keybinding to dismiss the info bar.
The close signal is a [keybinding signal](class.SignalAction.html).
The default binding for this signal is the Escape key.
method handler ( Int :$_handle_id, N-GObject :$_native-object, Gnome::Gtk4::InfoBar :$_widget, *C<user>-options )
$_handle_id; The registered event handler id.
$_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gtk4::InfoBar object.
$_widget; The object which registered the signal. User code may have left the object going out of scope.
user
-options; A list of named arguments provided at the.register-signal()
method from Gnome::GObject::Object.
response
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.
method handler ( gint $response-id, Int :$_handle_id, N-GObject :$_native-object, Gnome::Gtk4::InfoBar :$_widget, *C<user>-options )
$response-id; the response ID.
$_handle_id; The registered event handler id.
$_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gtk4::InfoBar object.
$_widget; The object which registered the signal. User code may have left the object going out of scope.
user
-options; A list of named arguments provided at the.register-signal()
method from Gnome::GObject::Object.