Class Widget.WidgetClass

All Implemented Interfaces:
Proxy
Direct Known Subclasses:
Avatar.AvatarClass, Banner.BannerClass, Bin.BinClass, BottomSheet.BottomSheetClass, Box.BoxClass, BreakpointBin.BreakpointBinClass, Button.ButtonClass, ButtonContent.ButtonContentClass, Carousel.CarouselClass, CarouselIndicatorDots.CarouselIndicatorDotsClass, CarouselIndicatorLines.CarouselIndicatorLinesClass, CheckButton.CheckButtonClass, Clamp.ClampClass, ClampScrollable.ClampScrollableClass, ColorDialogButton.ColorDialogButtonClass, ComboBox.ComboBoxClass, CompletionCell.CompletionCellClass, Dialog.DialogClass, DragIcon.DragIconClass, DrawingArea.DrawingAreaClass, DropDown.DropDownClass, EditableLabel.EditableLabelClass, Entry.EntryClass, Fixed.FixedClass, Flap.FlapClass, FlowBoxChild.FlowBoxChildClass, FontDialogButton.FontDialogButtonClass, Frame.FrameClass, GLArea.GLAreaClass, GraphicsOffload.GraphicsOffloadClass, Grid.GridClass, Gutter.GutterClass, GutterRenderer.GutterRendererClass, HeaderBar.HeaderBarClass, HoverDisplay.HoverDisplayClass, InlineViewSwitcher.InlineViewSwitcherClass, Inscription.InscriptionClass, LayoutSlot.LayoutSlotClass, Leaflet.LeafletClass, ListBoxRow.ListBoxRowClass, MediaControls.MediaControlsClass, MultiLayoutView.MultiLayoutViewClass, NavigationPage.NavigationPageClass, NavigationSplitView.NavigationSplitViewClass, NavigationView.NavigationViewClass, OverlaySplitView.OverlaySplitViewClass, Picture.PictureClass, Popover.PopoverClass, PopoverBin.PopoverBinClass, PreferencesGroup.PreferencesGroupClass, PreferencesPage.PreferencesPageClass, Range.RangeClass, ScaleButton.ScaleButtonClass, ShortcutLabel.ShortcutLabelClass, Sidebar.SidebarClass, Spinner.SpinnerClass, SplitButton.SplitButtonClass, Squeezer.SqueezerClass, StatusPage.StatusPageClass, StyleSchemeChooserWidget.StyleSchemeChooserWidgetClass, StyleSchemePreview.StyleSchemePreviewClass, TabBar.TabBarClass, TabButton.TabButtonClass, TabOverview.TabOverviewClass, TabView.TabViewClass, TextView.TextViewClass, ToastOverlay.ToastOverlayClass, ToggleGroup.ToggleGroupClass, ToolbarView.ToolbarViewClass, TreeExpander.TreeExpanderClass, TreeView.TreeViewClass, Video.VideoClass, ViewStack.ViewStackClass, ViewSwitcher.ViewSwitcherClass, ViewSwitcherBar.ViewSwitcherBarClass, ViewSwitcherSidebar.ViewSwitcherSidebarClass, ViewSwitcherTitle.ViewSwitcherTitleClass, WebViewBase.WebViewBaseClass, Window.WindowClass, WindowControls.WindowControlsClass, WindowHandle.WindowHandleClass, WindowTitle.WindowTitleClass, WrapBox.WrapBoxClass
Enclosing class:
Widget

public static class Widget.WidgetClass extends InitiallyUnowned.InitiallyUnownedClass
  • Constructor Details

    • WidgetClass

      public WidgetClass(MemorySegment address)
      Create a WidgetClass proxy instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
  • Method Details

    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • overrideShow

      public void overrideShow(Arena arena, @Nullable Method method)
      Override virtual method show.
      Parameters:
      method - the method to invoke
    • overrideHide

      public void overrideHide(Arena arena, @Nullable Method method)
      Override virtual method hide.
      Parameters:
      method - the method to invoke
    • overrideMap

      public void overrideMap(Arena arena, @Nullable Method method)
      Override virtual method map.
      Parameters:
      method - the method to invoke
    • overrideUnmap

      public void overrideUnmap(Arena arena, @Nullable Method method)
      Override virtual method unmap.
      Parameters:
      method - the method to invoke
    • overrideRealize

      public void overrideRealize(Arena arena, @Nullable Method method)
      Override virtual method realize.
      Parameters:
      method - the method to invoke
    • overrideUnrealize

      public void overrideUnrealize(Arena arena, @Nullable Method method)
      Override virtual method unrealize.
      Parameters:
      method - the method to invoke
    • overrideRoot

      public void overrideRoot(Arena arena, @Nullable Method method)
      Override virtual method root.
      Parameters:
      method - the method to invoke
    • overrideUnroot

      public void overrideUnroot(Arena arena, @Nullable Method method)
      Override virtual method unroot.
      Parameters:
      method - the method to invoke
    • overrideSizeAllocate

      public void overrideSizeAllocate(Arena arena, @Nullable Method method)
      Override virtual method size_allocate.
      Parameters:
      method - the method to invoke
    • overrideStateFlagsChanged

      public void overrideStateFlagsChanged(Arena arena, @Nullable Method method)
      Override virtual method state_flags_changed.
      Parameters:
      method - the method to invoke
    • overrideDirectionChanged

      public void overrideDirectionChanged(Arena arena, @Nullable Method method)
      Override virtual method direction_changed.
      Parameters:
      method - the method to invoke
    • overrideGetRequestMode

      public void overrideGetRequestMode(Arena arena, @Nullable Method method)
      Override virtual method get_request_mode.
      Parameters:
      method - the method to invoke
    • overrideMeasure

      public void overrideMeasure(Arena arena, @Nullable Method method)
      Override virtual method measure.
      Parameters:
      method - the method to invoke
    • overrideMnemonicActivate

      public void overrideMnemonicActivate(Arena arena, @Nullable Method method)
      Override virtual method mnemonic_activate.
      Parameters:
      method - the method to invoke
    • overrideGrabFocus

      public void overrideGrabFocus(Arena arena, @Nullable Method method)
      Override virtual method grab_focus.
      Parameters:
      method - the method to invoke
    • overrideFocus

      public void overrideFocus(Arena arena, @Nullable Method method)
      Override virtual method focus.
      Parameters:
      method - the method to invoke
    • overrideSetFocusChild

      public void overrideSetFocusChild(Arena arena, @Nullable Method method)
      Override virtual method set_focus_child.
      Parameters:
      method - the method to invoke
    • overrideMoveFocus

      public void overrideMoveFocus(Arena arena, @Nullable Method method)
      Override virtual method move_focus.
      Parameters:
      method - the method to invoke
    • overrideKeynavFailed

      public void overrideKeynavFailed(Arena arena, @Nullable Method method)
      Override virtual method keynav_failed.
      Parameters:
      method - the method to invoke
    • overrideQueryTooltip

      public void overrideQueryTooltip(Arena arena, @Nullable Method method)
      Override virtual method query_tooltip.
      Parameters:
      method - the method to invoke
    • overrideComputeExpand

      public void overrideComputeExpand(Arena arena, @Nullable Method method)
      Override virtual method compute_expand.
      Parameters:
      method - the method to invoke
    • overrideCssChanged

      public void overrideCssChanged(Arena arena, @Nullable Method method)
      Override virtual method css_changed.
      Parameters:
      method - the method to invoke
    • overrideSystemSettingChanged

      public void overrideSystemSettingChanged(Arena arena, @Nullable Method method)
      Override virtual method system_setting_changed.
      Parameters:
      method - the method to invoke
    • overrideSnapshot

      public void overrideSnapshot(Arena arena, @Nullable Method method)
      Override virtual method snapshot.
      Parameters:
      method - the method to invoke
    • overrideContains

      public void overrideContains(Arena arena, @Nullable Method method)
      Override virtual method contains.
      Parameters:
      method - the method to invoke
    • addBinding

      public void addBinding(int keyval, Set<ModifierType> mods, @Nullable ShortcutFunc callback, @Nullable String formatString, Object... varargs)

      Creates a new shortcut for this WidgetClass that calls the given callback with arguments according to formatString.

      The arguments and format string must be provided in the same way as with Variant(String, Object...).

      This function is a convenience wrapper around WidgetClass.addShortcut and must be called during class initialization. It does not provide for user data, if you need that, you will have to use WidgetClass.addShortcut with a custom shortcut.

      Parameters:
      keyval - key value of binding to install
      mods - key modifier of binding to install
      callback - the callback to call upon activation
      formatString - GVariant format string for arguments
      varargs - arguments, as given by format string
    • addBinding

      public void addBinding(int keyval, ModifierType mods, @Nullable ShortcutFunc callback, @Nullable String formatString, Object... varargs)

      Creates a new shortcut for this WidgetClass that calls the given callback with arguments according to formatString.

      The arguments and format string must be provided in the same way as with Variant(String, Object...).

      This function is a convenience wrapper around WidgetClass.addShortcut and must be called during class initialization. It does not provide for user data, if you need that, you will have to use WidgetClass.addShortcut with a custom shortcut.

      Parameters:
      keyval - key value of binding to install
      mods - key modifier of binding to install
      callback - the callback to call upon activation
      formatString - GVariant format string for arguments
      varargs - arguments, as given by format string
    • addBindingAction

      public void addBindingAction(int keyval, Set<ModifierType> mods, String actionName, @Nullable String formatString, Object... varargs)

      Creates a new shortcut for this WidgetClass that activates the given actionName with arguments read according to formatString.

      The arguments and format string must be provided in the same way as with Variant(String, Object...).

      This function is a convenience wrapper around WidgetClass.addShortcut and must be called during class initialization.

      Parameters:
      keyval - key value of binding to install
      mods - key modifier of binding to install
      actionName - the action to activate
      formatString - GVariant format string for arguments
      varargs - arguments, as given by format string
    • addBindingAction

      public void addBindingAction(int keyval, ModifierType mods, String actionName, @Nullable String formatString, Object... varargs)

      Creates a new shortcut for this WidgetClass that activates the given actionName with arguments read according to formatString.

      The arguments and format string must be provided in the same way as with Variant(String, Object...).

      This function is a convenience wrapper around WidgetClass.addShortcut and must be called during class initialization.

      Parameters:
      keyval - key value of binding to install
      mods - key modifier of binding to install
      actionName - the action to activate
      formatString - GVariant format string for arguments
      varargs - arguments, as given by format string
    • addBindingSignal

      public void addBindingSignal(int keyval, Set<ModifierType> mods, String signal, @Nullable String formatString, Object... varargs)

      Creates a new shortcut for this WidgetClass that emits the given action signal with arguments read according to formatString.

      The arguments and format string must be provided in the same way as with Variant(String, Object...).

      This function is a convenience wrapper around WidgetClass.addShortcut and must be called during class initialization.

      Parameters:
      keyval - key value of binding to install
      mods - key modifier of binding to install
      signal - the signal to execute
      formatString - GVariant format string for arguments
      varargs - arguments, as given by format string
    • addBindingSignal

      public void addBindingSignal(int keyval, ModifierType mods, String signal, @Nullable String formatString, Object... varargs)

      Creates a new shortcut for this WidgetClass that emits the given action signal with arguments read according to formatString.

      The arguments and format string must be provided in the same way as with Variant(String, Object...).

      This function is a convenience wrapper around WidgetClass.addShortcut and must be called during class initialization.

      Parameters:
      keyval - key value of binding to install
      mods - key modifier of binding to install
      signal - the signal to execute
      formatString - GVariant format string for arguments
      varargs - arguments, as given by format string
    • addShortcut

      public void addShortcut(Shortcut shortcut)

      Installs a shortcut in widgetClass.

      Every instance created for this WidgetClass or its subclasses will inherit this shortcut and trigger it.

      Shortcuts added this way will be triggered in the Gtk.PropagationPhase.bubble phase, which means they may also trigger if child widgets have focus.

      This function must only be used in class initialization functions otherwise it is not guaranteed that the shortcut will be installed.

      Parameters:
      shortcut - the shortcut to add
    • bindTemplateCallbackFull

      public void bindTemplateCallbackFull(String callbackName, @Nullable Callback callbackSymbol)

      Associates a name to be used in GtkBuilder XML with a symbol.

      This function is not supported after WidgetClass.setTemplateScope has been used on widgetClass.

      See BuilderCScope.addCallbackSymbol(String, Callback).

      Note that this must be called from a composite widget classes class initializer after calling WidgetClass.setTemplate.

      Parameters:
      callbackName - name of the callback as expected in the template XML
      callbackSymbol - the callback symbol
    • bindTemplateChildFull

      public void bindTemplateChildFull(String name, boolean internalChild, long structOffset)

      Assigns an object declared in the class template XML to be set to a location on a freshly built instance’s private data, or alternatively accessible via Widget.getTemplateChild(Type, String).

      The struct can point either into the public instance, then you should use G_STRUCT_OFFSET(WidgetType, member) for structOffset, or in the private struct, then you should use G_PRIVATE_OFFSET(WidgetType, member).

      An explicit strong reference will be held automatically for the duration of your instance’s life cycle, it will be released automatically when GObjectClass.dispose() runs on your instance and if a nonzero structOffset is specified, then the automatic location in your instance public or private data will be set to NULL. You can however access an automated child pointer the first time your classes GObjectClass.dispose() runs, or alternatively in Gtk.Widget::destroy.

      If internalChild is specified, Buildable.getInternalChild will be automatically implemented by the widget class so there is no need to implement it manually.

      The wrapper macros Gtk.widgetClassBindTemplateChild, Gtk.widgetClassBindTemplateChildInternal, Gtk.widgetClassBindTemplateChildPrivate and Gtk.widgetClassBindTemplateChildInternalPrivate might be more convenient to use.

      Note that this must be called from a composite widget classes class initializer after calling WidgetClass.setTemplate.

      Parameters:
      name - ID of the child defined in the template XML
      internalChild - whether the child should be accessible as an “internal-child” when this class is used in GtkBuilder XML
      structOffset - The offset into the composite widget’s instance public or private structure where the automated child pointer should be set, or 0 to not assign the pointer
    • getAccessibleRole

      public AccessibleRole getAccessibleRole()

      Retrieves the accessible role used by the given widget class.

      Different accessible roles have different states, and are rendered differently by assistive technologies.

      See also: Accessible.getAccessibleRole().

      Returns:
      the accessible role for the widget class
    • getActivateSignal

      public int getActivateSignal()

      Retrieves the signal id for the activation signal.

      The activation signal is set using WidgetClass.setActivateSignal.

      Returns:
      a signal id, or 0 if the widget class does not specify an activation signal
    • getCssName

      public String getCssName()

      Gets the name used by this class for matching in CSS code.

      See WidgetClass.setCssName for details.

      Returns:
      the CSS name of the given class
    • getLayoutManagerType

      public Type getLayoutManagerType()

      Retrieves the type of the LayoutManager used by widgets of class widgetClass.

      See also: WidgetClass.setLayoutManagerType.

      Returns:
      type of a GtkLayoutManager subclass, or G_TYPE_INVALID
    • installAction

      public void installAction(String actionName, @Nullable String parameterType, @Nullable WidgetActionActivateFunc activate)

      Adds an action for all instances of a widget class.

      This function should be called at class initialization time.

      Actions installed by this function are stateless. The only state they have is whether they are enabled or not (which can be changed with Widget.actionSetEnabled(String, boolean)).

      Parameters:
      actionName - a prefixed action name, such as "clipboard.paste"
      parameterType - the parameter type
      activate - callback to use when the action is activated
    • installPropertyAction

      public void installPropertyAction(String actionName, String propertyName)

      Installs an action called actionName on this WidgetClass and binds its state to the value of the propertyName property.

      This function will perform a few sanity checks on the property selected via propertyName. Namely, the property must exist, must be readable, writable and must not be construct-only. There are also restrictions on the type of the given property, it must be boolean, int, unsigned int, double or string. If any of these conditions are not met, a critical warning will be printed and no action will be added.

      The state type of the action matches the property type.

      If the property is boolean, the action will have no parameter and toggle the property value. Otherwise, the action will have a parameter of the same type as the property.

      Parameters:
      actionName - name of the action
      propertyName - name of a property in instances of this WidgetClass or any parent class
    • queryAction

      public boolean queryAction(int index, Type owner, Out<String> actionName, @Nullable Out<VariantType> parameterType, @Nullable Out<String> propertyName)

      Returns details about an action that has been installed for widgetClass.

      See WidgetClass.installAction for details on how to install actions.

      Note that this function will also return actions defined by parent classes. You can identify those by looking at owner.

      Parameters:
      index - position of the action to query
      owner - return location for the type where the action was defined
      actionName - return location for the action name
      parameterType - return location for the parameter type
      propertyName - return location for the property name
      Returns:
      true if the action was found
    • setAccessibleRole

      public void setAccessibleRole(AccessibleRole accessibleRole)

      Sets the accessible role used by the given widget class.

      Different accessible roles have different states, and are rendered differently by assistive technologies.

      Parameters:
      accessibleRole - the accessible role to use
    • setActivateSignal

      public void setActivateSignal(int signalId)

      Sets the activation signal for a widget class.

      The signal will be emitted when calling Widget.activate.

      The signalId must have been registered with GObject.signal_newv before calling this function.

      Parameters:
      signalId - the id for the activate signal
    • setActivateSignalFromName

      public void setActivateSignalFromName(String signalName)

      Sets the activation signal for a widget class.

      The signal id will by looked up by signalName.

      The signal will be emitted when calling Widget.activate.

      The signalName must have been registered with GObject.signal_newv before calling this function.

      Parameters:
      signalName - the name of the activate signal of widgetType
    • setCssName

      public void setCssName(String name)

      Sets the name to be used for CSS matching of widgets.

      If this function is not called for a given class, the name set on the parent class is used. By default, GtkWidget uses the name "widget".

      Parameters:
      name - name to use
    • setLayoutManagerType

      public void setLayoutManagerType(Type type)

      Sets the type to be used for creating layout managers for widgets of widgetClass.

      The given type must be a subtype of LayoutManager.

      This function should only be called from class init functions of widgets.

      Parameters:
      type - the object type that implements the GtkLayoutManager for this WidgetClass
    • setTemplate

      public void setTemplate(byte[] templateBytes)

      This should be called at class initialization time to specify the GtkBuilder XML to be used to extend a widget.

      For convenience, WidgetClass.setTemplateFromResource is also provided.

      Note that any class that installs templates must call Widget.initTemplate() in the widget’s instance initializer.

      Parameters:
      templateBytes - GBytes holding the GtkBuilder XML
    • setTemplateFromResource

      public void setTemplateFromResource(String resourceName)

      A convenience function that calls WidgetClass.setTemplate with the contents of a resource.

      Note that any class that installs templates must call Widget.initTemplate() in the widget’s instance initializer.

      Parameters:
      resourceName - resource path to load the template from
    • setTemplateScope

      public void setTemplateScope(BuilderScope scope)

      Overrides the default scope to be used when parsing the class template.

      This function is intended for language bindings.

      Note that this must be called from a composite widget classes class initializer after calling WidgetClass.setTemplate.

      Parameters:
      scope - GtkBuilderScope to use when loading the class template