Package ch.bailu.gtk.gtk
Class InfoBar
- All Implemented Interfaces:
PointerInterface
`GtkInfoBar` can be show messages to the user without a dialog.
![An example GtkInfoBar](info-bar.png)
It is often temporarily shown at the top or bottom of a document.
In contrast to [class@Gtk.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 [method@Gtk.InfoBar.add_button]
or [ctor@Gtk.InfoBar.new_with_buttons]. The sensitivity of action widgets
can be controlled with [method@Gtk.InfoBar.set_response_sensitive].
To add widgets to the main content area of a `GtkInfoBar`, use
[method@Gtk.InfoBar.add_child].
Similar to [class@Gtk.MessageDialog], the contents of a `GtkInfoBar`
can by classified as error message, warning, informational message, etc,
by using [method@Gtk.InfoBar.set_message_type]. GTK may use the message
type to determine how the message is displayed.
A simple example for using a `GtkInfoBar`:
```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
`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.
![An example GtkInfoBar](info-bar.png)
It is often temporarily shown at the top or bottom of a document.
In contrast to [class@Gtk.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 [method@Gtk.InfoBar.add_button]
or [ctor@Gtk.InfoBar.new_with_buttons]. The sensitivity of action widgets
can be controlled with [method@Gtk.InfoBar.set_response_sensitive].
To add widgets to the main content area of a `GtkInfoBar`, use
[method@Gtk.InfoBar.add_child].
Similar to [class@Gtk.MessageDialog], the contents of a `GtkInfoBar`
can by classified as error message, warning, informational message, etc,
by using [method@Gtk.InfoBar.set_message_type]. GTK may use the message
type to determine how the message is displayed.
A simple example for using a `GtkInfoBar`:
```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
`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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
Nested classes/interfaces inherited from class ch.bailu.gtk.gtk.Widget
Widget.OnDestroy, Widget.OnDestroyNotify, Widget.OnDirectionChanged, Widget.OnHide, Widget.OnKeynavFailed, Widget.OnMap, Widget.OnMnemonicActivate, Widget.OnMoveFocus, Widget.OnQueryTooltip, Widget.OnRealize, Widget.OnShow, Widget.OnStateFlagsChanged, Widget.OnTickCallback, Widget.OnUnmap, Widget.OnUnrealize
Nested classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Field Summary
Fields inherited from class ch.bailu.gtk.gtk.Widget
SIGNAL_ON_DESTROY, SIGNAL_ON_DIRECTION_CHANGED, SIGNAL_ON_HIDE, SIGNAL_ON_KEYNAV_FAILED, SIGNAL_ON_MAP, SIGNAL_ON_MNEMONIC_ACTIVATE, SIGNAL_ON_MOVE_FOCUS, SIGNAL_ON_QUERY_TOOLTIP, SIGNAL_ON_REALIZE, SIGNAL_ON_SHOW, SIGNAL_ON_STATE_FLAGS_CHANGED, SIGNAL_ON_UNMAP, SIGNAL_ON_UNREALIZE
Fields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Constructor Summary
ConstructorDescriptionInfoBar()
Creates a new `GtkInfoBar` object.InfoBar
(PointerContainer pointer) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addActionWidget
(Widget child, int response_id) Add an activatable widget to the action area of a `GtkInfoBar`.Adds a button with the given text.Adds a button with the given text.void
addButtons
(Str first_button_text, Object... _elipse) Adds multiple buttons.void
addButtons
(String first_button_text, Object... _elipse) Adds multiple buttons.void
Adds a widget to the content area of the info bar.Implements interfaceAccessible
.Implements interfaceBuildable
.Implements interfaceConstraintTarget
.static ClassHandler
static int
int
Returns the message type of the message area.static long
static TypeSystem.TypeSize
boolean
Returns whether the info bar is currently revealed.boolean
Returns whether the widget will display a standard close button.static long
static TypeSystem.TypeSize
static InfoBar
newWithButtonsInfoBar
(Str first_button_text, Object... _elipse) Creates a new `GtkInfoBar` with buttons.static InfoBar
newWithButtonsInfoBar
(String first_button_text, Object... _elipse) Creates a new `GtkInfoBar` with buttons.onClose
(InfoBar.OnClose signal) Connect to signal "close".onResponse
(InfoBar.OnResponse signal) Connect to signal "response".void
removeActionWidget
(Widget widget) Removes a widget from the action area of @info_bar.void
removeChild
(Widget widget) Removes a widget from the content area of the info bar.void
response
(int response_id) Emits the “response” signal with the given @response_id.void
setDefaultResponse
(int 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.void
setMessageType
(int message_type) Sets the message type of the message area.void
setResponseSensitive
(int response_id, boolean setting) Sets the sensitivity of action widgets for @response_id.void
setRevealed
(boolean revealed) Sets whether the `GtkInfoBar` is revealed.void
setShowCloseButton
(boolean setting) If true, a standard close button is shown.Methods inherited from class ch.bailu.gtk.gtk.Widget
actionSetEnabled, actionSetEnabled, activate, activateAction, activateAction, activateActionVariant, activateActionVariant, activateDefault, addController, addCssClass, addCssClass, addMnemonicLabel, addTickCallback, allocate, childFocus, computeBounds, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, createPangoLayout, disposeTemplate, dragCheckThreshold, errorBell, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getCanFocus, getCanTarget, getChildVisible, getClipboard, getCssClasses, getCssName, getCursor, getDefaultDirection, getDirection, getDisplay, getFirstChild, getFocusable, getFocusChild, getFocusOnClick, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHeight, getHexpand, getHexpandSet, getLastChild, getLayoutManager, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getName, getNative, getNextSibling, getOpacity, getOverflow, getPangoContext, getParent, getPreferredSize, getPrevSibling, getPrimaryClipboard, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSensitive, getSettings, getSize, getSizeRequest, getStateFlags, getStyleContext, getTemplateChild, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getVexpand, getVexpandSet, getVisible, getWidth, grabFocus, hasCssClass, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, observeChildren, observeControllers, onDestroy, onDirectionChanged, onHide, onKeynavFailed, onMap, onMnemonicActivate, onMoveFocus, onQueryTooltip, onRealize, onShow, onStateFlagsChanged, onUnmap, onUnrealize, pick, queueAllocate, queueDraw, queueResize, realize, removeController, removeCssClass, removeCssClass, removeMnemonicLabel, removeTickCallback, setCanFocus, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setCursorFromName, setDefaultDirection, setDirection, setFocusable, setFocusChild, setFocusOnClick, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setLayoutManager, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setName, setOpacity, setOverflow, setParent, setReceivesDefault, setSensitive, setSizeRequest, setStateFlags, setTooltipMarkup, setTooltipMarkup, setTooltipText, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible, shouldLayout, show, sizeAllocate, snapshotChild, triggerTooltipQuery, unmap, unparent, unrealize, unsetStateFlags
Methods inherited from class ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Field Details
-
SIGNAL_ON_CLOSE
- See Also:
-
SIGNAL_ON_RESPONSE
- See Also:
-
-
Constructor Details
-
InfoBar
-
InfoBar
public InfoBar()Creates a new `GtkInfoBar` object.
-
-
Method Details
-
getClassHandler
-
newWithButtonsInfoBar
Creates a new `GtkInfoBar` with buttons.
Button text/response ID pairs should be listed, with a %NULL 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 [signal@Gtk.InfoBar::response] signal with the corresponding
response ID.- Parameters:
first_button_text
- ext to go in first button_elipse
- response ID for first button, then additional buttons, ending with %NULL- Returns:
- a new `GtkInfoBar`
-
newWithButtonsInfoBar
Creates a new `GtkInfoBar` with buttons.
Button text/response ID pairs should be listed, with a %NULL 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 [signal@Gtk.InfoBar::response] signal with the corresponding
response ID.- Parameters:
first_button_text
- ext to go in first button_elipse
- response ID for first button, then additional buttons, ending with %NULL- Returns:
- a new `GtkInfoBar`
-
addActionWidget
Add an activatable widget to the action area of a `GtkInfoBar`.
This also connects a signal handler that will emit the
[signal@Gtk.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.- Parameters:
child
- an activatable widgetresponse_id
- response ID for @child
-
addButton
Adds a button with the given text.
Clicking the button will emit the [signal@Gtk.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.- Parameters:
button_text
- text of buttonresponse_id
- response ID for the button- Returns:
- the `GtkButton` widget that was added
-
addButton
Adds a button with the given text.
Clicking the button will emit the [signal@Gtk.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.- Parameters:
button_text
- text of buttonresponse_id
- response ID for the button- Returns:
- the `GtkButton` widget that was added
-
addButtons
Adds multiple buttons.
This is the same as calling [method@Gtk.InfoBar.add_button]
repeatedly. The variable argument list should be %NULL-terminated
as with [ctor@Gtk.InfoBar.new_with_buttons]. Each button must have both
text and response ID.- Parameters:
first_button_text
- button text_elipse
- response ID for first button, then more text-response_id pairs, ending with %NULL
-
addButtons
Adds multiple buttons.
This is the same as calling [method@Gtk.InfoBar.add_button]
repeatedly. The variable argument list should be %NULL-terminated
as with [ctor@Gtk.InfoBar.new_with_buttons]. Each button must have both
text and response ID.- Parameters:
first_button_text
- button text_elipse
- response ID for first button, then more text-response_id pairs, ending with %NULL
-
addChild
Adds a widget to the content area of the info bar.- Parameters:
widget
- the child to be added
-
getMessageType
public int getMessageType()Returns the message type of the message area.- Returns:
- the message type of the message area.
-
getRevealed
public boolean getRevealed()Returns whether the info bar is currently revealed.- Returns:
- the current value of the [property@Gtk.InfoBar:revealed] property
-
getShowCloseButton
public boolean getShowCloseButton()Returns whether the widget will display a standard close button.- Returns:
- %TRUE if the widget displays standard close button
-
removeActionWidget
Removes a widget from the action area of @info_bar.
The widget must have been put there by a call to
[method@Gtk.InfoBar.add_action_widget] or [method@Gtk.InfoBar.add_button].- Parameters:
widget
- an action widget to remove
-
removeChild
Removes a widget from the content area of the info bar.- Parameters:
widget
- a child that has been added to the content area
-
response
public void response(int response_id) Emits the “response” signal with the given @response_id.- Parameters:
response_id
- a response ID
-
setDefaultResponse
public void setDefaultResponse(int 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 @info_bar to
be added to a widget hierarchy.- Parameters:
response_id
- a response ID
-
setMessageType
public void setMessageType(int message_type) Sets the message type of the message area.
GTK uses this type to determine how the message is displayed.- Parameters:
message_type
- a `GtkMessageType`
-
setResponseSensitive
public void setResponseSensitive(int response_id, boolean setting) 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.- Parameters:
response_id
- a response IDsetting
- TRUE for sensitive
-
setRevealed
public void setRevealed(boolean revealed) Sets whether the `GtkInfoBar` 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
[property@Gtk.Widget:visible] sense, so revealing has no effect
if [property@Gtk.Widget:visible] is %FALSE.- Parameters:
revealed
- The new value of the property
-
setShowCloseButton
public void setShowCloseButton(boolean setting) If true, a standard close button is shown.
When clicked it emits the response %GTK_RESPONSE_CLOSE.- Parameters:
setting
- %TRUE to include a close button
-
onClose
Connect to signal "close".
SeeInfoBar.OnClose.onClose()
for signal description.
FieldSIGNAL_ON_CLOSE
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
onResponse
Connect to signal "response".
SeeInfoBar.OnResponse.onResponse(int)
for signal description.
FieldSIGNAL_ON_RESPONSE
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
asAccessible
Implements interfaceAccessible
. Call this to get access to interface functions.- Overrides:
asAccessible
in classWidget
- Returns:
Accessible
-
asBuildable
Implements interfaceBuildable
. Call this to get access to interface functions.- Overrides:
asBuildable
in classWidget
- Returns:
Buildable
-
asConstraintTarget
Implements interfaceConstraintTarget
. Call this to get access to interface functions.- Overrides:
asConstraintTarget
in classWidget
- Returns:
ConstraintTarget
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-