Class Widget.Builder<B extends Widget.Builder<B>>

Type Parameters:
B - the type of the Builder that is returned
All Implemented Interfaces:
Accessible.Builder<B>, BuilderInterface
Direct Known Subclasses:
ActionBar.Builder, AppChooserButton.Builder, AppChooserWidget.Builder, AspectFrame.Builder, Avatar.Builder, Banner.Builder, Bin.Builder, BottomSheet.Builder, Box.Builder, BreakpointBin.Builder, Button.Builder, ButtonContent.Builder, Calendar.Builder, Carousel.Builder, CarouselIndicatorDots.Builder, CarouselIndicatorLines.Builder, CellView.Builder, CenterBox.Builder, CheckButton.Builder, Clamp.Builder, ClampScrollable.Builder, ColorButton.Builder, ColorChooserWidget.Builder, ColorDialogButton.Builder, ColumnView.Builder, ComboBox.Builder, CompletionCell.Builder, Dialog.Builder, DragIcon.Builder, DrawingArea.Builder, DropDown.Builder, EditableLabel.Builder, Entry.Builder, Expander.Builder, FileChooserWidget.Builder, Fixed.Builder, Flap.Builder, FlowBox.Builder, FlowBoxChild.Builder, FontButton.Builder, FontChooserWidget.Builder, FontDialogButton.Builder, Frame.Builder, GLArea.Builder, GraphicsOffload.Builder, Grid.Builder, Gutter.Builder, GutterRenderer.Builder, HeaderBar.Builder, HeaderBar.Builder, HoverDisplay.Builder, IconView.Builder, Image.Builder, InfoBar.Builder, InlineViewSwitcher.Builder, Inscription.Builder, Label.Builder, LayoutSlot.Builder, Leaflet.Builder, LevelBar.Builder, ListBase.Builder, ListBox.Builder, ListBoxRow.Builder, MediaControls.Builder, MenuButton.Builder, MultiLayoutView.Builder, NavigationPage.Builder, NavigationSplitView.Builder, NavigationView.Builder, Notebook.Builder, Overlay.Builder, OverlaySplitView.Builder, Paned.Builder, PasswordEntry.Builder, Picture.Builder, Popover.Builder, PopoverBin.Builder, PopoverMenuBar.Builder, PreferencesGroup.Builder, PreferencesPage.Builder, ProgressBar.Builder, Range.Builder, Revealer.Builder, ScaleButton.Builder, Scrollbar.Builder, ScrolledWindow.Builder, SearchBar.Builder, SearchEntry.Builder, Separator.Builder, ShortcutLabel.Builder, ShortcutLabel.Builder, ShortcutsShortcut.Builder, Sidebar.Builder, SpinButton.Builder, Spinner.Builder, Spinner.Builder, SplitButton.Builder, Squeezer.Builder, Stack.Builder, StackSidebar.Builder, StackSwitcher.Builder, Statusbar.Builder, StatusPage.Builder, StyleSchemeChooserWidget.Builder, StyleSchemePreview.Builder, Switch.Builder, TabBar.Builder, TabButton.Builder, TabOverview.Builder, TabView.Builder, Text.Builder, TextView.Builder, ToastOverlay.Builder, ToggleGroup.Builder, ToolbarView.Builder, TreeExpander.Builder, TreeView.Builder, Video.Builder, Viewport.Builder, ViewStack.Builder, ViewSwitcher.Builder, ViewSwitcherBar.Builder, ViewSwitcherSidebar.Builder, ViewSwitcherTitle.Builder, WebViewBase.Builder, Window.Builder, WindowControls.Builder, WindowHandle.Builder, WindowTitle.Builder, WrapBox.Builder
Enclosing class:
Widget

public static class Widget.Builder<B extends Widget.Builder<B>> extends InitiallyUnowned.Builder<B> implements Accessible.Builder<B>
Inner class implementing a builder pattern to construct a GObject with properties.
  • Constructor Details

    • Builder

      protected Builder()
      Default constructor for a Builder object.
  • Method Details

    • build

      public Widget build()
      Finish building the Widget object. This will call GObject.withProperties(Type, String[], Value[]) to create a new GObject instance, which is then cast to Widget.
      Overrides:
      build in class InitiallyUnowned.Builder<B extends Widget.Builder<B>>
      Returns:
      a new instance of Widget with the properties that were set in the Builder object.
    • setCanFocus

      public B setCanFocus(boolean canFocus)

      Whether the widget or any of its descendents can accept the input focus.

      This property is meant to be set by widget implementations, typically in their instance init function.

      Parameters:
      canFocus - the value for the can-focus property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setCanTarget

      public B setCanTarget(boolean canTarget)
      Whether the widget can receive pointer events.
      Parameters:
      canTarget - the value for the can-target property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setCssClasses

      public B setCssClasses(String[] cssClasses)
      A list of css classes applied to this widget.
      Parameters:
      cssClasses - the value for the css-classes property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setCssName

      public B setCssName(String cssName)

      The name of this widget in the CSS tree.

      This property is meant to be set by widget implementations, typically in their instance init function.

      Parameters:
      cssName - the value for the css-name property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setCursor

      public B setCursor(Cursor cursor)
      The cursor used by widget.
      Parameters:
      cursor - the value for the cursor property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setFocusOnClick

      public B setFocusOnClick(boolean focusOnClick)

      Whether the widget should grab focus when it is clicked with the mouse.

      This property is only relevant for widgets that can take focus.

      Parameters:
      focusOnClick - the value for the focus-on-click property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setFocusable

      public B setFocusable(boolean focusable)
      Whether this widget itself will accept the input focus.
      Parameters:
      focusable - the value for the focusable property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setHalign

      public B setHalign(Align halign)
      How to distribute horizontal space if widget gets extra space.
      Parameters:
      halign - the value for the halign property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setHasTooltip

      public B setHasTooltip(boolean hasTooltip)

      Enables or disables the emission of the Gtk.Widget::query-tooltip signal on widget.

      A true value indicates that widget can have a tooltip, in this case the widget will be queried using Gtk.Widget::query-tooltip to determine whether it will provide a tooltip or not.

      Parameters:
      hasTooltip - the value for the has-tooltip property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setHeightRequest

      public B setHeightRequest(int heightRequest)

      Overrides for height request of the widget.

      If this is -1, the natural request will be used.

      Parameters:
      heightRequest - the value for the height-request property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setHexpand

      public B setHexpand(boolean hexpand)
      Whether to expand horizontally.
      Parameters:
      hexpand - the value for the hexpand property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setHexpandSet

      public B setHexpandSet(boolean hexpandSet)
      Whether to use the hexpand property.
      Parameters:
      hexpandSet - the value for the hexpand-set property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setLayoutManager

      public B setLayoutManager(LayoutManager layoutManager)

      The LayoutManager instance to use to compute the preferred size of the widget, and allocate its children.

      This property is meant to be set by widget implementations, typically in their instance init function.

      Parameters:
      layoutManager - the value for the layout-manager property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setLimitEvents

      public B setLimitEvents(boolean limitEvents)

      Makes this widget act like a modal dialog, with respect to event delivery.

      Global event controllers will not handle events with targets inside the widget, unless they are set up to ignore propagation limits. See EventController.setPropagationLimit(PropagationLimit).

      Parameters:
      limitEvents - the value for the limit-events property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      4.18
    • setMarginBottom

      public B setMarginBottom(int marginBottom)

      Margin on bottom side of widget.

      This property adds margin outside of the widget's normal size request, the margin will be added in addition to the size from Widget.setSizeRequest(int, int) for example.

      Parameters:
      marginBottom - the value for the margin-bottom property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setMarginEnd

      public B setMarginEnd(int marginEnd)

      Margin on end of widget, horizontally.

      This property supports left-to-right and right-to-left text directions.

      This property adds margin outside of the widget's normal size request, the margin will be added in addition to the size from Widget.setSizeRequest(int, int) for example.

      Parameters:
      marginEnd - the value for the margin-end property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setMarginStart

      public B setMarginStart(int marginStart)

      Margin on start of widget, horizontally.

      This property supports left-to-right and right-to-left text directions.

      This property adds margin outside of the widget's normal size request, the margin will be added in addition to the size from Widget.setSizeRequest(int, int) for example.

      Parameters:
      marginStart - the value for the margin-start property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setMarginTop

      public B setMarginTop(int marginTop)

      Margin on top side of widget.

      This property adds margin outside of the widget's normal size request, the margin will be added in addition to the size from Widget.setSizeRequest(int, int) for example.

      Parameters:
      marginTop - the value for the margin-top property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setName

      public B setName(String name)
      The name of the widget.
      Parameters:
      name - the value for the name property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setOpacity

      public B setOpacity(double opacity)
      The requested opacity of the widget.
      Parameters:
      opacity - the value for the opacity property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setOverflow

      public B setOverflow(Overflow overflow)

      How content outside the widget's content area is treated.

      This property is meant to be set by widget implementations, typically in their instance init function.

      Parameters:
      overflow - the value for the overflow property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setReceivesDefault

      public B setReceivesDefault(boolean receivesDefault)
      Whether the widget will receive the default action when it is focused.
      Parameters:
      receivesDefault - the value for the receives-default property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setSensitive

      public B setSensitive(boolean sensitive)
      Whether the widget responds to input.
      Parameters:
      sensitive - the value for the sensitive property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setTooltipMarkup

      public B setTooltipMarkup(String tooltipMarkup)

      Sets the text of tooltip to be the given string, which is marked up with Pango markup.

      Also see Tooltip.setMarkup(String).

      This is a convenience property which will take care of getting the tooltip shown if the given string is not NULL: Gtk.Widget:has-tooltip will automatically be set to true and there will be taken care of Gtk.Widget::query-tooltip in the default signal handler.

      Note that if both Gtk.Widget:tooltip-text and Gtk.Widget:tooltip-markup are set, the last one wins.

      Parameters:
      tooltipMarkup - the value for the tooltip-markup property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setTooltipText

      public B setTooltipText(String tooltipText)

      Sets the text of tooltip to be the given string.

      Also see Tooltip.setText(String).

      This is a convenience property which will take care of getting the tooltip shown if the given string is not NULL: Gtk.Widget:has-tooltip will automatically be set to true and there will be taken care of Gtk.Widget::query-tooltip in the default signal handler.

      Note that if both Gtk.Widget:tooltip-text and Gtk.Widget:tooltip-markup are set, the last one wins.

      Parameters:
      tooltipText - the value for the tooltip-text property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setValign

      public B setValign(Align valign)
      How to distribute vertical space if widget gets extra space.
      Parameters:
      valign - the value for the valign property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setVexpand

      public B setVexpand(boolean vexpand)
      Whether to expand vertically.
      Parameters:
      vexpand - the value for the vexpand property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setVexpandSet

      public B setVexpandSet(boolean vexpandSet)
      Whether to use the vexpand property.
      Parameters:
      vexpandSet - the value for the vexpand-set property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setVisible

      public B setVisible(boolean visible)
      Whether the widget is visible.
      Parameters:
      visible - the value for the visible property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setWidthRequest

      public B setWidthRequest(int widthRequest)

      Overrides for width request of the widget.

      If this is -1, the natural request will be used.

      Parameters:
      widthRequest - the value for the width-request property
      Returns:
      the Builder instance is returned, to allow method chaining
    • onDestroy

      public B onDestroy(Widget.DestroyCallback handler)

      Signals that all holders of a reference to the widget should release the reference that they hold.

      May result in finalization of the widget if all references are released.

      This signal is not suitable for saving widget state.

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onDirectionChanged

      public B onDirectionChanged(Widget.DirectionChangedCallback handler)
      Emitted when the text direction of a widget changes.
      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onHide

      public B onHide(Widget.HideCallback handler)
      Emitted when widget is hidden.
      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onKeynavFailed

      public B onKeynavFailed(Widget.KeynavFailedCallback handler)

      Emitted if keyboard navigation fails.

      See Widget.keynavFailed(DirectionType) for details.

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onMap

      public B onMap(Widget.MapCallback handler)

      Emitted when widget is going to be mapped.

      A widget is mapped when the widget is visible (which is controlled with Gtk.Widget:visible) and all its parents up to the toplevel widget are also visible.

      The ::map signal can be used to determine whether a widget will be drawn, for instance it can resume an animation that was stopped during the emission of Gtk.Widget::unmap.

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onMnemonicActivate

      public B onMnemonicActivate(Widget.MnemonicActivateCallback handler)

      Emitted when a widget is activated via a mnemonic.

      The default handler for this signal activates widget if groupCycling is false, or just makes widget grab focus if groupCycling is true.

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onMoveFocus

      public B onMoveFocus(Widget.MoveFocusCallback handler)

      Emitted when the focus is moved.

      The ::move-focus signal is a keybinding signal.

      The default bindings for this signal are Tab to move forward, and Shift+Tab to move backward.

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onQueryTooltip

      public B onQueryTooltip(Widget.QueryTooltipCallback handler)

      Emitted when the widget’s tooltip is about to be shown.

      This happens when the Gtk.Widget:has-tooltip property is true and the hover timeout has expired with the cursor hovering above widget; or emitted when widget got focus in keyboard mode.

      Using the given coordinates, the signal handler should determine whether a tooltip should be shown for widget. If this is the case true should be returned, false otherwise. Note that if keyboardMode is true, the values of x and y are undefined and should not be used.

      The signal handler is free to manipulate tooltip with the therefore destined function calls.

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onRealize

      public B onRealize(Widget.RealizeCallback handler)

      Emitted when widget is associated with a GdkSurface.

      This means that Widget.realize() has been called or the widget has been mapped (that is, it is going to be drawn).

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onShow

      public B onShow(Widget.ShowCallback handler)
      Emitted when widget is shown.
      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onStateFlagsChanged

      public B onStateFlagsChanged(Widget.StateFlagsChangedCallback handler)

      Emitted when the widget state changes.

      See Widget.getStateFlags().

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onUnmap

      public B onUnmap(Widget.UnmapCallback handler)

      Emitted when widget is going to be unmapped.

      A widget is unmapped when either it or any of its parents up to the toplevel widget have been set as hidden.

      As ::unmap indicates that a widget will not be shown any longer, it can be used to, for example, stop an animation on the widget.

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onUnrealize

      public B onUnrealize(Widget.UnrealizeCallback handler)

      Emitted when the GdkSurface associated with widget is destroyed.

      This means that Widget.unrealize() has been called or the widget has been unmapped (that is, it is going to be hidden).

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also: