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
,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
,Spinner.SpinnerClass
,SplitButton.SplitButtonClass
,Squeezer.SqueezerClass
,StatusPage.StatusPageClass
,StyleSchemeChooserWidget.StyleSchemeChooserWidgetClass
,StyleSchemePreview.StyleSchemePreviewClass
,TabBar.TabBarClass
,TabButton.TabButtonClass
,TabOverview.TabOverviewClass
,TabView.TabViewClass
,TextView.TextViewClass
,ToastOverlay.ToastOverlayClass
,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
- Enclosing class:
Widget
-
Constructor Summary
ConstructorDescriptionAllocate a new WidgetClass.WidgetClass
(Arena arena) Allocate a new WidgetClass.WidgetClass
(MemorySegment address) Create a WidgetClass proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addBinding
(int keyval, Set<ModifierType> mods, ShortcutFunc callback, @Nullable String formatString, Object... varargs) Creates a new shortcut for this WidgetClass that calls the givencallback
with arguments read according toformatString
.void
addBinding
(int keyval, ModifierType mods, ShortcutFunc callback, @Nullable String formatString, Object... varargs) Creates a new shortcut for this WidgetClass that calls the givencallback
with arguments read according toformatString
.void
addBindingAction
(int keyval, Set<ModifierType> mods, String actionName, @Nullable String formatString, Object... varargs) Creates a new shortcut for this WidgetClass that activates the givenactionName
with arguments read according toformatString
.void
addBindingAction
(int keyval, ModifierType mods, String actionName, @Nullable String formatString, Object... varargs) Creates a new shortcut for this WidgetClass that activates the givenactionName
with arguments read according toformatString
.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 actionsignal
with arguments read according toformatString
.void
addBindingSignal
(int keyval, ModifierType mods, String signal, @Nullable String formatString, Object... varargs) Creates a new shortcut for this WidgetClass that emits the given actionsignal
with arguments read according toformatString
.void
addShortcut
(Shortcut shortcut) Installs a shortcut in this WidgetClass.void
bindTemplateCallbackFull
(String callbackName, Callback callbackSymbol) Declares acallbackSymbol
to handlecallbackName
from the template XML defined forwidgetType
.void
bindTemplateChildFull
(String name, boolean internalChild, long structOffset) Automatically assign 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 givenGtkWidget
class.int
Retrieves the signal id for the activation signal.Gets the name used by this class for matching in CSS code.Retrieves the type of theLayoutManager
used by widgets of class this WidgetClass.static MemoryLayout
The memory layout of the native struct.void
installAction
(String actionName, @Nullable String parameterType, WidgetActionActivateFunc activate) This should be called at class initialization time to specify actions to be added for all instances of this class.void
installPropertyAction
(String actionName, String propertyName) Installs an action calledactionName
on this WidgetClass and binds its state to the value of thepropertyName
property.void
overrideComputeExpand
(Arena arena, Method method) Override virtual methodcompute_expand
.void
overrideContains
(Arena arena, Method method) Override virtual methodcontains
.void
overrideCssChanged
(Arena arena, Method method) Override virtual methodcss_changed
.void
overrideDirectionChanged
(Arena arena, Method method) Override virtual methoddirection_changed
.void
overrideFocus
(Arena arena, Method method) Override virtual methodfocus
.void
overrideGetRequestMode
(Arena arena, Method method) Override virtual methodget_request_mode
.void
overrideGrabFocus
(Arena arena, Method method) Override virtual methodgrab_focus
.void
overrideHide
(Arena arena, Method method) Override virtual methodhide
.void
overrideKeynavFailed
(Arena arena, Method method) Override virtual methodkeynav_failed
.void
overrideMap
(Arena arena, Method method) Override virtual methodmap
.void
overrideMeasure
(Arena arena, Method method) Override virtual methodmeasure
.void
overrideMnemonicActivate
(Arena arena, Method method) Override virtual methodmnemonic_activate
.void
overrideMoveFocus
(Arena arena, Method method) Override virtual methodmove_focus
.void
overrideQueryTooltip
(Arena arena, Method method) Override virtual methodquery_tooltip
.void
overrideRealize
(Arena arena, Method method) Override virtual methodrealize
.void
overrideRoot
(Arena arena, Method method) Override virtual methodroot
.void
overrideSetFocusChild
(Arena arena, Method method) Override virtual methodset_focus_child
.void
overrideShow
(Arena arena, Method method) Override virtual methodshow
.void
overrideSizeAllocate
(Arena arena, Method method) Override virtual methodsize_allocate
.void
overrideSnapshot
(Arena arena, Method method) Override virtual methodsnapshot
.void
overrideStateFlagsChanged
(Arena arena, Method method) Override virtual methodstate_flags_changed
.void
overrideSystemSettingChanged
(Arena arena, Method method) Override virtual methodsystem_setting_changed
.void
overrideUnmap
(Arena arena, Method method) Override virtual methodunmap
.void
overrideUnrealize
(Arena arena, Method method) Override virtual methodunrealize
.void
overrideUnroot
(Arena arena, Method method) Override virtual methodunroot
.boolean
queryAction
(int index, Type owner, Out<String> actionName, @Nullable Out<VariantType> parameterType, @Nullable Out<String> propertyName) Returns details about theindex
-th action that has been installed for this WidgetClass during class initialization.void
setAccessibleRole
(AccessibleRole accessibleRole) Sets the accessible role used by the givenGtkWidget
class.void
setActivateSignal
(int signalId) Sets theGtkWidgetClass.activate_signal
field with the givensignalId
.void
setActivateSignalFromName
(String signalName) Sets theGtkWidgetClass.activate_signal
field with the signal id for the givensignalName
.void
setCssName
(String name) Sets the name to be used for CSS matching of widgets.void
setLayoutManagerType
(Type type) Sets the type to be used for creating layout managers for widgets of this WidgetClass.void
setTemplate
(Bytes templateBytes) This should be called at class initialization time to specify theGtkBuilder
XML to be used to extend a widget.void
setTemplateFromResource
(String resourceName) A convenience function that callsWidgetClass#setTemplate
with the contents of aGResource
.void
setTemplateScope
(BuilderScope scope) For use in language bindings, this will override the defaultGtkBuilderScope
to be used when parsing GtkBuilder XML from this class’s template data.Methods inherited from class org.gnome.gobject.GObject.ObjectClass
findProperty, installProperties, installProperty, listProperties, overrideConstructed, overrideConstructor, overrideDispatchPropertiesChanged, overrideDispose, overrideFinalize, overrideGetProperty, overrideNotify, overrideProperty, overrideSetProperty, readFlags, readNConstructProperties, readNPspecs, readPdummy, readPspecs, writeFlags, writeNConstructProperties, writeNPspecs, writePdummy, writePspecs
Methods inherited from class org.gnome.gobject.TypeClass
addPrivate, adjustPrivateOffset, getInstancePrivateOffset, getPrivate, peek, peekParent, peekStatic, readGType, ref, unref, unrefUncached, writeGType
Methods inherited from class io.github.jwharm.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
-
WidgetClass
Allocate a new WidgetClass.- Parameters:
arena
- to control the memory allocation scope
-
WidgetClass
public WidgetClass()Allocate a new WidgetClass. The memory is allocated withArena.ofAuto()
.
-
-
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, ShortcutFunc callback, @Nullable @Nullable String formatString, Object... varargs) Creates a new shortcut for this WidgetClass that calls the givencallback
with arguments read according toformatString
.The arguments and format string must be provided in the same way as with g_variant_new().
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 useWidgetClass#addShortcut
with a custom shortcut.- Parameters:
keyval
- key value of binding to installmods
- key modifier of binding to installcallback
- the callback to call upon activationformatString
- GVariant format string for arguments ornull
for no argumentsvarargs
- arguments, as given by format string
-
addBinding
public void addBinding(int keyval, ModifierType mods, ShortcutFunc callback, @Nullable @Nullable String formatString, Object... varargs) Creates a new shortcut for this WidgetClass that calls the givencallback
with arguments read according toformatString
.The arguments and format string must be provided in the same way as with g_variant_new().
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 useWidgetClass#addShortcut
with a custom shortcut.- Parameters:
keyval
- key value of binding to installmods
- key modifier of binding to installcallback
- the callback to call upon activationformatString
- GVariant format string for arguments ornull
for no argumentsvarargs
- arguments, as given by format string
-
addBindingAction
public void addBindingAction(int keyval, Set<ModifierType> mods, String actionName, @Nullable @Nullable String formatString, Object... varargs) Creates a new shortcut for this WidgetClass that activates the givenactionName
with arguments read according toformatString
.The arguments and format string must be provided in the same way as with g_variant_new().
This function is a convenience wrapper around
WidgetClass#addShortcut
and must be called during class initialization.- Parameters:
keyval
- key value of binding to installmods
- key modifier of binding to installactionName
- the action to activateformatString
- GVariant format string for arguments ornull
for no argumentsvarargs
- arguments, as given by format string
-
addBindingAction
public void addBindingAction(int keyval, ModifierType mods, String actionName, @Nullable @Nullable String formatString, Object... varargs) Creates a new shortcut for this WidgetClass that activates the givenactionName
with arguments read according toformatString
.The arguments and format string must be provided in the same way as with g_variant_new().
This function is a convenience wrapper around
WidgetClass#addShortcut
and must be called during class initialization.- Parameters:
keyval
- key value of binding to installmods
- key modifier of binding to installactionName
- the action to activateformatString
- GVariant format string for arguments ornull
for no argumentsvarargs
- arguments, as given by format string
-
addBindingSignal
public void addBindingSignal(int keyval, Set<ModifierType> mods, String signal, @Nullable @Nullable String formatString, Object... varargs) Creates a new shortcut for this WidgetClass that emits the given actionsignal
with arguments read according toformatString
.The arguments and format string must be provided in the same way as with g_variant_new().
This function is a convenience wrapper around
WidgetClass#addShortcut
and must be called during class initialization.- Parameters:
keyval
- key value of binding to installmods
- key modifier of binding to installsignal
- the signal to executeformatString
- GVariant format string for arguments ornull
for no argumentsvarargs
- arguments, as given by format string
-
addBindingSignal
public void addBindingSignal(int keyval, ModifierType mods, String signal, @Nullable @Nullable String formatString, Object... varargs) Creates a new shortcut for this WidgetClass that emits the given actionsignal
with arguments read according toformatString
.The arguments and format string must be provided in the same way as with g_variant_new().
This function is a convenience wrapper around
WidgetClass#addShortcut
and must be called during class initialization.- Parameters:
keyval
- key value of binding to installmods
- key modifier of binding to installsignal
- the signal to executeformatString
- GVariant format string for arguments ornull
for no argumentsvarargs
- arguments, as given by format string
-
addShortcut
Installs a shortcut in this 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
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
- theGtkShortcut
to add
-
bindTemplateCallbackFull
Declares acallbackSymbol
to handlecallbackName
from the template XML defined forwidgetType
.This function is not supported after
WidgetClass#setTemplateScope
has been used on this WidgetClass. SeeBuilderCScope.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
- The name of the callback as expected in the template XMLcallbackSymbol
- The callback symbol
-
bindTemplateChildFull
Automatically assign 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 astructOffset
that is!= 0
is 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
internalChild
is specified,Buildable#getInternalChild
will be automatically implemented by theGtkWidget
class so there is no need to implement it manually.The wrapper macros
Gtk#widgetClassBindTemplateChild
,Gtk#widgetClassBindTemplateChildInternal
,Gtk#widgetClassBindTemplateChildPrivate
andGtk#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
- The “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 structure 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 givenGtkWidget
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#setCssName
for details.- Returns:
- the CSS name of the given class
-
getLayoutManagerType
Retrieves the type of theLayoutManager
used by widgets of class this WidgetClass.See also:
WidgetClass#setLayoutManagerType
.- Returns:
- type of a
GtkLayoutManager
subclass, orG_TYPE_INVALID
-
installAction
public void installAction(String actionName, @Nullable @Nullable String parameterType, WidgetActionActivateFunc activate) This should be called at class initialization time to specify actions to be added for all instances of this class.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 calledactionName
on this WidgetClass and binds its state to the value of thepropertyName
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 actionpropertyName
- name of the property in instances of this WidgetClass or any parent class.
-
queryAction
public boolean queryAction(int index, Type owner, Out<String> actionName, @Nullable @Nullable Out<VariantType> parameterType, @Nullable @Nullable Out<String> propertyName) Returns details about theindex
-th action that has been installed for this WidgetClass during class initialization.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 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,false
ifindex
is out of range
-
setAccessibleRole
Sets the accessible role used by the givenGtkWidget
class.Different accessible roles have different states, and are rendered differently by assistive technologies.
- Parameters:
accessibleRole
- theGtkAccessibleRole
used by the this WidgetClass
-
setActivateSignal
public void setActivateSignal(int signalId) Sets theGtkWidgetClass.activate_signal
field with the givensignalId
.The signal will be emitted when calling
Widget#activate
.The
signalId
must have been registered withg_signal_new()
or g_signal_newv() before calling this function.- Parameters:
signalId
- the id for the activate signal
-
setActivateSignalFromName
Sets theGtkWidgetClass.activate_signal
field with the signal id for the givensignalName
.The signal will be emitted when calling
Widget#activate
.The
signalName
ofwidgetType
must have been registered with g_signal_new() or g_signal_newv() 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,
GtkWidget
uses the name "widget".- Parameters:
name
- name to use
-
setLayoutManagerType
Sets the type to be used for creating layout managers for widgets of this WidgetClass.The given
type
must be a subtype ofLayoutManager
.This function should only be called from class init functions of widgets.
- Parameters:
type
- The object type that implements theGtkLayoutManager
for this WidgetClass
-
setTemplate
This should be called at class initialization time to specify theGtkBuilder
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
- AGBytes
holding theGtkBuilder
XML
-
setTemplateFromResource
A convenience function that callsWidgetClass#setTemplate
with the contents of aGResource
.Note that any class that installs templates must call
Widget.initTemplate()
in the widget’s instance initializer.- Parameters:
resourceName
- The name of the resource to load the template from
-
setTemplateScope
For use in language bindings, this will override the defaultGtkBuilderScope
to be used when parsing GtkBuilder XML from this class’s template data.Note that this must be called from a composite widget classes class initializer after calling
WidgetClass#setTemplate
.- Parameters:
scope
- TheGtkBuilderScope
to use when loading the class template
-