Class Label.Builder<B extends Label.Builder<B>>
- Type Parameters:
B- the type of the Builder that is returned
- All Implemented Interfaces:
Accessible.Builder<B>,BuilderInterface
- Enclosing class:
Label
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Finish building theLabelobject.Gets emitted when the user activates a link in the label.onActivateLink(Label.ActivateLinkCallback handler) Gets emitted to activate a URI.Gets emitted to copy the selection to the clipboard.onMoveCursor(Label.MoveCursorCallback handler) Gets emitted when the user initiates a cursor movement.setAttributes(AttrList attributes) A list of style attributes to apply to the text of the label.setEllipsize(EllipsizeMode ellipsize) The preferred place to ellipsize the string, if the label does not have enough room to display the entire string.setExtraMenu(MenuModel extraMenu) A menu model whose contents will be appended to the context menu.setJustify(Justification justify) The alignment of the lines in the text of the label, relative to each other.The contents of the label.setLines(int lines) The number of lines to which an ellipsized, wrapping label should display before it gets ellipsized.setMaxWidthChars(int maxWidthChars) The desired maximum width of the label, in characters.setMnemonicWidget(Widget mnemonicWidget) The widget to be activated when the labels mnemonic key is pressed.setNaturalWrapMode(NaturalWrapMode naturalWrapMode) Select the line wrapping for the natural size request.setSelectable(boolean selectable) Whether the label text can be selected with the mouse.setSingleLineMode(boolean singleLineMode) Whether the label is in single line mode.Custom tabs for this label.setUseMarkup(boolean useMarkup) True if the text of the label includes Pango markup.setUseUnderline(boolean useUnderline) True if the text of the label indicates a mnemonic with an_before the mnemonic character.setWidthChars(int widthChars) The desired width of the label, in characters.setWrap(boolean wrap) True if the label text will wrap if it gets too wide.setWrapMode(WrapMode wrapMode) Controls how the line wrapping is done.setXalign(float xalign) The horizontal alignment of the label text inside its size allocation.setYalign(float yalign) The vertical alignment of the label text inside its size allocation.Methods inherited from class org.gnome.gtk.Widget.Builder
onDestroy, onDirectionChanged, onHide, onKeynavFailed, onMap, onMnemonicActivate, onMoveFocus, onQueryTooltip, onRealize, onShow, onStateFlagsChanged, onUnmap, onUnrealize, setCanFocus, setCanTarget, setCssClasses, setCssName, setCursor, setFocusable, setFocusOnClick, setHalign, setHasTooltip, setHeightRequest, setHexpand, setHexpandSet, setLayoutManager, setLimitEvents, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setOpacity, setOverflow, setReceivesDefault, setSensitive, setTooltipMarkup, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible, setWidthRequestMethods inherited from class org.gnome.gobject.GObject.Builder
onNotifyMethods inherited from class org.javagi.gobject.Builder
addBuilderProperty, connect, connect, connectSignals, getArena, getNames, getValuesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.gnome.gtk.Accessible.Builder
setAccessibleRoleMethods inherited from interface org.javagi.gobject.BuilderInterface
addBuilderProperty, connect, connect, getArena
-
Constructor Details
-
Builder
protected Builder()Default constructor for aBuilderobject.
-
-
Method Details
-
build
Finish building theLabelobject. This will callGObject.withProperties(org.gnome.glib.Type, java.lang.String[], org.gnome.gobject.Value[])to create a new GObject instance, which is then cast toLabel.- Overrides:
buildin classWidget.Builder<B extends Label.Builder<B>>- Returns:
- a new instance of
Labelwith the properties that were set in the Builder object.
-
setAttributes
-
setEllipsize
The preferred place to ellipsize the string, if the label does not have enough room to display the entire string.Note that setting this property to a value other than [enum.Pango.EllipsizeMode.none] has the side-effect that the label requests only enough space to display the ellipsis "...". In particular, this means that ellipsizing labels do not work well in notebook tabs, unless the
Gtk.NotebookPage:tab-expandchild property is set to true.Other ways to set a label's width are
Widget.setSizeRequest(int, int)andLabel.setWidthChars(int).- Parameters:
ellipsize- the value for theellipsizeproperty- Returns:
- the
Builderinstance is returned, to allow method chaining
-
setExtraMenu
-
setJustify
The alignment of the lines in the text of the label, relative to each other.This does not affect the alignment of the label within its allocation. See
Gtk.Label:xalignfor that.- Parameters:
justify- the value for thejustifyproperty- Returns:
- the
Builderinstance is returned, to allow method chaining
-
setLabel
The contents of the label.If the string contains Pango markup (see
Pango.parseMarkup(java.lang.String, int, int, org.javagi.base.Out<org.gnome.pango.AttrList>, org.javagi.base.Out<java.lang.String>, org.javagi.base.Out<java.lang.Integer>)), you will have to set theGtk.Label:use-markupproperty to true in order for the label to display the markup attributes. See alsoLabel.setMarkup(java.lang.String)for a convenience function that sets both this property and theGtk.Label:use-markupproperty at the same time.If the string contains underlines acting as mnemonics, you will have to set the
Gtk.Label:use-underlineproperty to true in order for the label to display them.- Parameters:
label- the value for thelabelproperty- Returns:
- the
Builderinstance is returned, to allow method chaining
-
setLines
The number of lines to which an ellipsized, wrapping label should display before it gets ellipsized. This both prevents the label from ellipsizing before this many lines are displayed, and limits the height request of the label to this many lines.Warning Setting this property has unintuitive and unfortunate consequences for the minimum _width_ of the label. Specifically, if the height of the label is such that it fits a smaller number of lines than the value of this property, the label can not be ellipsized at all, which means it must be wide enough to fit all the text fully. This property has no effect if the label is not wrapping or ellipsized. Set this property to -1 if you don't want to limit the number of lines.
- Parameters:
lines- the value for thelinesproperty- Returns:
- the
Builderinstance is returned, to allow method chaining
-
setMaxWidthChars
The desired maximum width of the label, in characters.If this property is set to -1, the width will be calculated automatically.
See the section on text layout for details of how
Gtk.Label:width-charsandGtk.Label:max-width-charsdetermine the width of ellipsized and wrapped labels.- Parameters:
maxWidthChars- the value for themax-width-charsproperty- Returns:
- the
Builderinstance is returned, to allow method chaining
-
setMnemonicWidget
-
setNaturalWrapMode
Select the line wrapping for the natural size request.This only affects the natural size requested. For the actual wrapping used, see the
Gtk.Label:wrap-modeproperty.The default is
Gtk.NaturalWrapMode.inherit, which inherits the behavior of theGtk.Label:wrap-modeproperty.- Parameters:
naturalWrapMode- the value for thenatural-wrap-modeproperty- Returns:
- the
Builderinstance is returned, to allow method chaining - Since:
- 4.6
-
setSelectable
Whether the label text can be selected with the mouse.- Parameters:
selectable- the value for theselectableproperty- Returns:
- the
Builderinstance is returned, to allow method chaining
-
setSingleLineMode
Whether the label is in single line mode.In single line mode, the height of the label does not depend on the actual text, it is always set to ascent + descent of the font. This can be an advantage in situations where resizing the label because of text changes would be distracting, e.g. in a statusbar.
- Parameters:
singleLineMode- the value for thesingle-line-modeproperty- Returns:
- the
Builderinstance is returned, to allow method chaining
-
setTabs
-
setUseMarkup
True if the text of the label includes Pango markup.- Parameters:
useMarkup- the value for theuse-markupproperty- Returns:
- the
Builderinstance is returned, to allow method chaining
-
setUseUnderline
True if the text of the label indicates a mnemonic with an_before the mnemonic character.- Parameters:
useUnderline- the value for theuse-underlineproperty- Returns:
- the
Builderinstance is returned, to allow method chaining
-
setWidthChars
The desired width of the label, in characters.If this property is set to -1, the width will be calculated automatically.
See the section on text layout for details of how
Gtk.Label:width-charsandGtk.Label:max-width-charsdetermine the width of ellipsized and wrapped labels.- Parameters:
widthChars- the value for thewidth-charsproperty- Returns:
- the
Builderinstance is returned, to allow method chaining
-
setWrap
True if the label text will wrap if it gets too wide.- Parameters:
wrap- the value for thewrapproperty- Returns:
- the
Builderinstance is returned, to allow method chaining
-
setWrapMode
Controls how the line wrapping is done.This only affects the formatting if line wrapping is on (see the
Gtk.Label:wrapproperty). The default isPango.WrapMode.word, which means wrap on word boundaries.For sizing behavior, also consider the
Gtk.Label:natural-wrap-modeproperty.- Parameters:
wrapMode- the value for thewrap-modeproperty- Returns:
- the
Builderinstance is returned, to allow method chaining
-
setXalign
The horizontal alignment of the label text inside its size allocation.Compare this to
Gtk.Widget:halign, which determines how the labels size allocation is positioned in the space available for the label.- Parameters:
xalign- the value for thexalignproperty- Returns:
- the
Builderinstance is returned, to allow method chaining
-
setYalign
The vertical alignment of the label text inside its size allocation.Compare this to
Gtk.Widget:valign, which determines how the labels size allocation is positioned in the space available for the label.- Parameters:
yalign- the value for theyalignproperty- Returns:
- the
Builderinstance is returned, to allow method chaining
-
onActivateCurrentLink
Gets emitted when the user activates a link in the label.The
::activate-current-linkis a keybinding signal.Applications may also emit the signal with g_signal_emit_by_name() if they need to control activation of URIs programmatically.
The default bindings for this signal are all forms of the
Enterkey.- Parameters:
handler- the signal handler- Returns:
- the
Builderinstance is returned, to allow method chaining - See Also:
-
onActivateLink
Gets emitted to activate a URI.Applications may connect to it to override the default behaviour, which is to call
FileLauncher.launch(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback).- Parameters:
handler- the signal handler- Returns:
- the
Builderinstance is returned, to allow method chaining - See Also:
-
onCopyClipboard
Gets emitted to copy the selection to the clipboard.The
::copy-clipboardsignal is a keybinding signal.The default binding for this signal is
Ctrl+c.- Parameters:
handler- the signal handler- Returns:
- the
Builderinstance is returned, to allow method chaining - See Also:
-
onMoveCursor
Gets emitted when the user initiates a cursor movement.The
::move-cursorsignal is a keybinding signal. If the cursor is not visible inentry,this signal causes the viewport to be moved instead.Applications should not connect to it, but may emit it with
GObjects.signalEmitByName(org.gnome.gobject.GObject, java.lang.String, java.lang.Object...)if they need to control the cursor programmatically.The default bindings for this signal come in two variants, the variant with the
Shiftmodifier extends the selection, the variant without theShiftmodifier does not. There are too many key combinations to list them all here.←,→,↑,↓move by individual characters/linesCtrl+←, etc. move by words/paragraphsHomeandEndmove to the ends of the buffer
- Parameters:
handler- the signal handler- Returns:
- the
Builderinstance is returned, to allow method chaining - See Also:
-