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,PreferencesGroup.PreferencesGroupClass,PreferencesPage.PreferencesPageClass,Range.RangeClass,ScaleButton.ScaleButtonClass,ShortcutLabel.ShortcutLabelClass,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,ViewSwitcherTitle.ViewSwitcherTitleClass,WebViewBase.WebViewBaseClass,Window.WindowClass,WindowControls.WindowControlsClass,WindowHandle.WindowHandleClass,WindowTitle.WindowTitleClass,WrapBox.WrapBoxClass
- Enclosing class:
Widget
-
Constructor Summary
ConstructorsConstructorDescriptionWidgetClass(MemorySegment address) Create a WidgetClass proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBinding(int keyval, Set<ModifierType> mods, @Nullable ShortcutFunc callback, @Nullable String formatString, Object... varargs) Creates a new shortcut for this WidgetClass that calls the givencallbackwith arguments according toformatString.voidaddBinding(int keyval, ModifierType mods, @Nullable ShortcutFunc callback, @Nullable String formatString, Object... varargs) Creates a new shortcut for this WidgetClass that calls the givencallbackwith arguments according toformatString.voidaddBindingAction(int keyval, Set<ModifierType> mods, String actionName, @Nullable String formatString, Object... varargs) Creates a new shortcut for this WidgetClass that activates the givenactionNamewith arguments read according toformatString.voidaddBindingAction(int keyval, ModifierType mods, String actionName, @Nullable String formatString, Object... varargs) Creates a new shortcut for this WidgetClass that activates the givenactionNamewith arguments read according toformatString.voidaddBindingSignal(int keyval, Set<ModifierType> mods, String signal, @Nullable String formatString, Object... varargs) Creates a new shortcut for this WidgetClass that emits the given actionsignalwith arguments read according toformatString.voidaddBindingSignal(int keyval, ModifierType mods, String signal, @Nullable String formatString, Object... varargs) Creates a new shortcut for this WidgetClass that emits the given actionsignalwith arguments read according toformatString.voidaddShortcut(Shortcut shortcut) Installs a shortcut inwidgetClass.voidbindTemplateCallbackFull(String callbackName, @Nullable Callback callbackSymbol) Associates a name to be used in GtkBuilder XML with a symbol.voidbindTemplateChildFull(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 viaWidget.getTemplateChild(org.gnome.glib.Type, java.lang.String).Retrieves the accessible role used by the given widget class.intRetrieves the signal id for the activation signal.Gets the name used by this class for matching in CSS code.Retrieves the type of theLayoutManagerused by widgets of classwidgetClass.static MemoryLayoutThe memory layout of the native struct.voidinstallAction(String actionName, @Nullable String parameterType, @Nullable WidgetActionActivateFunc activate) Adds an action for all instances of a widget class.voidinstallPropertyAction(String actionName, String propertyName) Installs an action calledactionNameon this WidgetClass and binds its state to the value of thepropertyNameproperty.voidoverrideComputeExpand(Arena arena, @Nullable Method method) Override virtual methodcompute_expand.voidoverrideContains(Arena arena, @Nullable Method method) Override virtual methodcontains.voidoverrideCssChanged(Arena arena, @Nullable Method method) Override virtual methodcss_changed.voidoverrideDirectionChanged(Arena arena, @Nullable Method method) Override virtual methoddirection_changed.voidoverrideFocus(Arena arena, @Nullable Method method) Override virtual methodfocus.voidoverrideGetRequestMode(Arena arena, @Nullable Method method) Override virtual methodget_request_mode.voidoverrideGrabFocus(Arena arena, @Nullable Method method) Override virtual methodgrab_focus.voidoverrideHide(Arena arena, @Nullable Method method) Override virtual methodhide.voidoverrideKeynavFailed(Arena arena, @Nullable Method method) Override virtual methodkeynav_failed.voidoverrideMap(Arena arena, @Nullable Method method) Override virtual methodmap.voidoverrideMeasure(Arena arena, @Nullable Method method) Override virtual methodmeasure.voidoverrideMnemonicActivate(Arena arena, @Nullable Method method) Override virtual methodmnemonic_activate.voidoverrideMoveFocus(Arena arena, @Nullable Method method) Override virtual methodmove_focus.voidoverrideQueryTooltip(Arena arena, @Nullable Method method) Override virtual methodquery_tooltip.voidoverrideRealize(Arena arena, @Nullable Method method) Override virtual methodrealize.voidoverrideRoot(Arena arena, @Nullable Method method) Override virtual methodroot.voidoverrideSetFocusChild(Arena arena, @Nullable Method method) Override virtual methodset_focus_child.voidoverrideShow(Arena arena, @Nullable Method method) Override virtual methodshow.voidoverrideSizeAllocate(Arena arena, @Nullable Method method) Override virtual methodsize_allocate.voidoverrideSnapshot(Arena arena, @Nullable Method method) Override virtual methodsnapshot.voidoverrideStateFlagsChanged(Arena arena, @Nullable Method method) Override virtual methodstate_flags_changed.voidoverrideSystemSettingChanged(Arena arena, @Nullable Method method) Override virtual methodsystem_setting_changed.voidoverrideUnmap(Arena arena, @Nullable Method method) Override virtual methodunmap.voidoverrideUnrealize(Arena arena, @Nullable Method method) Override virtual methodunrealize.voidoverrideUnroot(Arena arena, @Nullable Method method) Override virtual methodunroot.booleanqueryAction(int index, Type owner, Out<String> actionName, @Nullable Out<VariantType> parameterType, @Nullable Out<String> propertyName) Returns details about an action that has been installed forwidgetClass.voidsetAccessibleRole(AccessibleRole accessibleRole) Sets the accessible role used by the given widget class.voidsetActivateSignal(int signalId) Sets the activation signal for a widget class.voidsetActivateSignalFromName(String signalName) Sets the activation signal for a widget class.voidsetCssName(String name) Sets the name to be used for CSS matching of widgets.voidsetLayoutManagerType(Type type) Sets the type to be used for creating layout managers for widgets ofwidgetClass.voidsetTemplate(byte[] templateBytes) This should be called at class initialization time to specify theGtkBuilderXML to be used to extend a widget.voidsetTemplateFromResource(String resourceName) A convenience function that callsWidgetClass#setTemplatewith the contents of a resource.voidsetTemplateScope(BuilderScope scope) Overrides the default scope to be used when parsing the class template.Methods inherited from class org.gnome.gobject.GObject.ObjectClass
findProperty, installProperties, installProperty, listProperties, overrideConstructed, overrideConstructor, overrideDispatchPropertiesChanged, overrideDispose, overrideFinalize, overrideGetProperty, overrideNotify, overrideProperty, overrideSetProperty, readConstructProperties, readFlags, readNConstructProperties, readNPspecs, readPdummy, readPspecs, writeConstructProperties, writeFlags, writeNConstructProperties, writeNPspecs, writePdummy, writePspecsMethods inherited from class org.gnome.gobject.TypeClass
addPrivate, adjustPrivateOffset, get, getInstancePrivateOffset, getPrivate, peek, peekParent, peekStatic, readGType, ref, unref, unrefUncached, writeGTypeMethods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
WidgetClass
Create a WidgetClass proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
-
Method Details
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
overrideShow
-
overrideHide
-
overrideMap
-
overrideUnmap
-
overrideRealize
-
overrideUnrealize
-
overrideRoot
-
overrideUnroot
-
overrideSizeAllocate
-
overrideStateFlagsChanged
-
overrideDirectionChanged
-
overrideGetRequestMode
-
overrideMeasure
-
overrideMnemonicActivate
-
overrideGrabFocus
-
overrideFocus
-
overrideSetFocusChild
-
overrideMoveFocus
-
overrideQueryTooltip
-
overrideComputeExpand
-
overrideCssChanged
-
overrideSystemSettingChanged
-
overrideSnapshot
-
overrideContains
-
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 givencallbackwith arguments according toformatString.The arguments and format string must be provided in the same way as with
Variant(java.lang.String, java.lang.Object...).This function is a convenience wrapper around
WidgetClass#addShortcutand must be called during class initialization. It does not provide for user data, if you need that, you will have to useWidgetClass#addShortcutwith a custom shortcut.- Parameters:
keyval- key value of binding to installmods- key modifier of binding to installcallback- the callback to call upon activationformatString-GVariantformat string for argumentsvarargs- 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 givencallbackwith arguments according toformatString.The arguments and format string must be provided in the same way as with
Variant(java.lang.String, java.lang.Object...).This function is a convenience wrapper around
WidgetClass#addShortcutand must be called during class initialization. It does not provide for user data, if you need that, you will have to useWidgetClass#addShortcutwith a custom shortcut.- Parameters:
keyval- key value of binding to installmods- key modifier of binding to installcallback- the callback to call upon activationformatString-GVariantformat string for argumentsvarargs- 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 givenactionNamewith arguments read according toformatString.The arguments and format string must be provided in the same way as with
Variant(java.lang.String, java.lang.Object...).This function is a convenience wrapper around
WidgetClass#addShortcutand must be called during class initialization.- Parameters:
keyval- key value of binding to installmods- key modifier of binding to installactionName- the action to activateformatString-GVariantformat string for argumentsvarargs- 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 givenactionNamewith arguments read according toformatString.The arguments and format string must be provided in the same way as with
Variant(java.lang.String, java.lang.Object...).This function is a convenience wrapper around
WidgetClass#addShortcutand must be called during class initialization.- Parameters:
keyval- key value of binding to installmods- key modifier of binding to installactionName- the action to activateformatString-GVariantformat string for argumentsvarargs- 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 actionsignalwith arguments read according toformatString.The arguments and format string must be provided in the same way as with
Variant(java.lang.String, java.lang.Object...).This function is a convenience wrapper around
WidgetClass#addShortcutand must be called during class initialization.- Parameters:
keyval- key value of binding to installmods- key modifier of binding to installsignal- the signal to executeformatString-GVariantformat string for argumentsvarargs- 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 actionsignalwith arguments read according toformatString.The arguments and format string must be provided in the same way as with
Variant(java.lang.String, java.lang.Object...).This function is a convenience wrapper around
WidgetClass#addShortcutand must be called during class initialization.- Parameters:
keyval- key value of binding to installmods- key modifier of binding to installsignal- the signal to executeformatString-GVariantformat string for argumentsvarargs- arguments, as given by format string
-
addShortcut
Installs a shortcut inwidgetClass.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.bubblephase, 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
Associates a name to be used in GtkBuilder XML with a symbol.This function is not supported after
WidgetClass#setTemplateScopehas been used onwidgetClass.See
BuilderCScope.addCallbackSymbol(java.lang.String, org.gnome.gobject.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 XMLcallbackSymbol- the callback symbol
-
bindTemplateChildFull
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 viaWidget.getTemplateChild(org.gnome.glib.Type, java.lang.String).The struct can point either into the public instance, then you should use
G_STRUCT_OFFSET(WidgetType, member)forstructOffset,or in the private struct, then you should useG_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 nonzerostructOffsetis specified, then the automatic location in your instance public or private data will be set toNULL. You can however access an automated child pointer the first time your classesGObjectClass.dispose()runs, or alternatively inGtk.Widget::destroy.If
internalChildis specified,Buildable#getInternalChildwill be automatically implemented by the widget class so there is no need to implement it manually.The wrapper macros
Gtk#widgetClassBindTemplateChild,Gtk#widgetClassBindTemplateChildInternal,Gtk#widgetClassBindTemplateChildPrivateandGtk#widgetClassBindTemplateChildInternalPrivatemight 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 XMLinternalChild- whether the child should be accessible as an “internal-child” when this class is used in GtkBuilder XMLstructOffset- 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
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
Gets the name used by this class for matching in CSS code.See
WidgetClass#setCssNamefor details.- Returns:
- the CSS name of the given class
-
getLayoutManagerType
Retrieves the type of theLayoutManagerused by widgets of classwidgetClass.See also:
WidgetClass#setLayoutManagerType.- Returns:
- type of a
GtkLayoutManagersubclass, orG_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(java.lang.String, boolean)).- Parameters:
actionName- a prefixed action name, such as "clipboard.paste"parameterType- the parameter typeactivate- callback to use when the action is activated
-
installPropertyAction
Installs an action calledactionNameon this WidgetClass and binds its state to the value of thepropertyNameproperty.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 actionpropertyName- 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 forwidgetClass.See
WidgetClass#installActionfor 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 queryowner- return location for the type where the action was definedactionName- return location for the action nameparameterType- return location for the parameter typepropertyName- return location for the property name- Returns:
- true if the action was found
-
setAccessibleRole
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
signalIdmust have been registered with [function.GObject.signal_new] orGObjects.signalNewv(java.lang.String, org.gnome.glib.Type, java.util.Set<org.gnome.gobject.SignalFlags>, org.gnome.gobject.Closure, org.gnome.gobject.SignalAccumulator, org.gnome.gobject.SignalCMarshaller, org.gnome.glib.Type, org.gnome.glib.Type[])before calling this function.- Parameters:
signalId- the id for the activate signal
-
setActivateSignalFromName
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
signalNamemust have been registered with [function.GObject.signal_new] orGObjects.signalNewv(java.lang.String, org.gnome.glib.Type, java.util.Set<org.gnome.gobject.SignalFlags>, org.gnome.gobject.Closure, org.gnome.gobject.SignalAccumulator, org.gnome.gobject.SignalCMarshaller, org.gnome.glib.Type, org.gnome.glib.Type[])before calling this function.- Parameters:
signalName- the name of the activate signal ofwidgetType
-
setCssName
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,
GtkWidgetuses the name "widget".- Parameters:
name- name to use
-
setLayoutManagerType
Sets the type to be used for creating layout managers for widgets ofwidgetClass.The given
typemust be a subtype ofLayoutManager.This function should only be called from class init functions of widgets.
- Parameters:
type- the object type that implements theGtkLayoutManagerfor this WidgetClass
-
setTemplate
public void setTemplate(byte[] templateBytes) This should be called at class initialization time to specify theGtkBuilderXML to be used to extend a widget.For convenience,
WidgetClass#setTemplateFromResourceis also provided.Note that any class that installs templates must call
Widget.initTemplate()in the widget’s instance initializer.- Parameters:
templateBytes-GBytesholding theGtkBuilderXML
-
setTemplateFromResource
A convenience function that callsWidgetClass#setTemplatewith 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
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-GtkBuilderScopeto use when loading the class template
-