Class Label.Builder<B extends Label.Builder<B>>
- Type Parameters:
B
- the type of the Builder that is returned
- All Implemented Interfaces:
BuilderInterface
,Accessible.Builder<B>
- Enclosing class:
Label
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Finish building theLabel
object.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 be limited.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, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setOpacity, setOverflow, setReceivesDefault, setSensitive, setTooltipMarkup, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible, setWidthRequest
Methods inherited from class org.gnome.gobject.GObject.Builder
onNotify
Methods inherited from class io.github.jwharm.javagi.gobject.Builder
addBuilderProperty, connect, connect, connectSignals, getArena, getNames, getValues
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.gnome.gtk.Accessible.Builder
setAccessibleRole
Methods inherited from interface io.github.jwharm.javagi.gobject.BuilderInterface
addBuilderProperty, connect, connect, getArena
-
Constructor Details
-
Builder
protected Builder()Default constructor for aBuilder
object.
-
-
Method Details
-
build
Finish building theLabel
object. 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:
build
in classWidget.Builder<B extends Label.Builder<B>>
- Returns:
- a new instance of
Label
with 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
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 theGtk.NotebookPage:tab-expand
child property is set totrue
. Other ways to set a label's width areWidget.setSizeRequest(int, int)
andLabel.setWidthChars(int)
.- Parameters:
ellipsize
- the value for theellipsize
property- Returns:
- the
Builder
instance 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:xalign
for that.- Parameters:
justify
- the value for thejustify
property- Returns:
- the
Builder
instance 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, io.github.jwharm.javagi.base.Out<org.gnome.pango.AttrList>, io.github.jwharm.javagi.base.Out<java.lang.String>, io.github.jwharm.javagi.base.Out<java.lang.Integer>)
), you will have to set theGtk.Label:use-markup
property totrue
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-markup
property at the same time.If the string contains underlines acting as mnemonics, you will have to set the
Gtk.Label:use-underline
property totrue
in order for the label to display them.- Parameters:
label
- the value for thelabel
property- Returns:
- the
Builder
instance is returned, to allow method chaining
-
setLines
The number of lines to which an ellipsized, wrapping label should be limited.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 thelines
property- Returns:
- the
Builder
instance 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-chars
andGtk.Label:max-width-chars
determine the width of ellipsized and wrapped labels.- Parameters:
maxWidthChars
- the value for themax-width-chars
property- Returns:
- the
Builder
instance 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-mode
property.The default is
NaturalWrapMode.INHERIT
, which inherits the behavior of theGtk.Label:wrap-mode
property.- Parameters:
naturalWrapMode
- the value for thenatural-wrap-mode
property- Returns:
- the
Builder
instance is returned, to allow method chaining
-
setSelectable
Whether the label text can be selected with the mouse.- Parameters:
selectable
- the value for theselectable
property- Returns:
- the
Builder
instance 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-mode
property- Returns:
- the
Builder
instance is returned, to allow method chaining
-
setTabs
-
setUseMarkup
true
if the text of the label includes Pango markup.- Parameters:
useMarkup
- the value for theuse-markup
property- Returns:
- the
Builder
instance 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-underline
property- Returns:
- the
Builder
instance 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-chars
andGtk.Label:max-width-chars
determine the width of ellipsized and wrapped labels.- Parameters:
widthChars
- the value for thewidth-chars
property- Returns:
- the
Builder
instance is returned, to allow method chaining
-
setWrap
true
if the label text will wrap if it gets too wide.- Parameters:
wrap
- the value for thewrap
property- Returns:
- the
Builder
instance 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:wrap
property). The default isWrapMode.WORD
, which means wrap on word boundaries.For sizing behavior, also consider the
Gtk.Label:natural-wrap-mode
property.- Parameters:
wrapMode
- the value for thewrap-mode
property- Returns:
- the
Builder
instance 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 thexalign
property- Returns:
- the
Builder
instance 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 theyalign
property- Returns:
- the
Builder
instance is returned, to allow method chaining
-
onActivateCurrentLink
Gets emitted when the user activates a link in the label.The ::activate-current-link is 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
Enter
key.- Parameters:
handler
- the signal handler- Returns:
- the
Builder
instance 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
Builder
instance is returned, to allow method chaining - See Also:
-
onCopyClipboard
Gets emitted to copy the selection to the clipboard.The ::copy-clipboard signal is a keybinding signal.
The default binding for this signal is
Ctrl
+c
.- Parameters:
handler
- the signal handler- Returns:
- the
Builder
instance is returned, to allow method chaining - See Also:
-
onMoveCursor
Gets emitted when the user initiates a cursor movement.The ::move-cursor signal is a keybinding signal. If the cursor is not visible in
entry
, this signal causes the viewport to be moved instead.Applications should not connect to it, but may emit it with g_signal_emit_by_name() if they need to control the cursor programmatically.
The default bindings for this signal come in two variants, the variant with the
Shift
modifier extends the selection, the variant without theShift
modifier does not. There are too many key combinations to list them all here.←
,→
,↑
,↓
move by individual characters/linesCtrl
+←
, etc. move by words/paragraphsHome
andEnd
move to the ends of the buffer
- Parameters:
handler
- the signal handler- Returns:
- the
Builder
instance is returned, to allow method chaining - See Also:
-