Class GObject.ObjectClass
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
AlertDialog.AlertDialogClass
,AppLaunchContext.AppLaunchContextClass
,Application.ApplicationClass
,ApplicationCommandLine.ApplicationCommandLineClass
,Auth.AuthClass
,AuthDomain.AuthDomainClass
,AuthenticationRequest.AuthenticationRequestClass
,AuthManager.AuthManagerClass
,AutomationSession.AutomationSessionClass
,BackForwardList.BackForwardListClass
,BookmarkList.BookmarkListClass
,Breakpoint.BreakpointClass
,BuilderCScope.BuilderCScopeClass
,Cache.CacheClass
,Cancellable.CancellableClass
,CellAreaContext.CellAreaContextClass
,CharsetConverter.CharsetConverterClass
,Class.ClassClass
,ClipboardPermissionRequest.ClipboardPermissionRequestClass
,ColorBalanceChannel.ColorBalanceChannelClass
,ColorChooserRequest.ColorChooserRequestClass
,ColorDialog.ColorDialogClass
,Completion.CompletionClass
,CompletionContext.CompletionContextClass
,CompletionSnippets.CompletionSnippetsClass
,CompletionWords.CompletionWordsClass
,Constraint.ConstraintClass
,ConstraintGuide.ConstraintGuideClass
,ContentDecoder.ContentDecoderClass
,ContentProvider.ContentProviderClass
,ContentSniffer.ContentSnifferClass
,Context.ContextClass
,ContextMenu.ContextMenuClass
,ContextMenu.ContextMenuClass
,CookieJar.CookieJarClass
,CookieManager.CookieManagerClass
,DataQueue.DataQueueClass
,DBusInterfaceSkeleton.DBusInterfaceSkeletonClass
,DBusObjectManagerClient.DBusObjectManagerClientClass
,DBusObjectManagerServer.DBusObjectManagerServerClass
,DBusObjectProxy.DBusObjectProxyClass
,DBusObjectSkeleton.DBusObjectSkeletonClass
,DBusProxy.DBusProxyClass
,DebugControllerDBus.DebugControllerDBusClass
,DesktopAppInfo.DesktopAppInfoClass
,DeviceInfoPermissionRequest.DeviceInfoPermissionRequestClass
,DirectoryList.DirectoryListClass
,Download.DownloadClass
,EditorState.EditorStateClass
,EmblemedIcon.EmblemedIconClass
,EntryBuffer.EntryBufferClass
,EnumListItem.EnumListItemClass
,EnumListModel.EnumListModelClass
,Exception.ExceptionClass
,FaviconDatabase.FaviconDatabaseClass
,File.FileClass
,FileChooserRequest.FileChooserRequestClass
,FileDialog.FileDialogClass
,FileEnumerator.FileEnumeratorClass
,FileLauncher.FileLauncherClass
,FileLoader.FileLoaderClass
,FileMonitor.FileMonitorClass
,FilenameCompleter.FilenameCompleterClass
,FileSaver.FileSaverClass
,Filter.FilterClass
,FilterListModel.FilterListModelClass
,FindController.FindControllerClass
,FlattenListModel.FlattenListModelClass
,Font.FontClass
,FontDialog.FontDialogClass
,FontFace.FontFaceClass
,FontFamily.FontFamilyClass
,FontMap.FontMapClass
,Fontset.FontsetClass
,FormSubmissionRequest.FormSubmissionRequestClass
,Frame.FrameClass
,GeolocationManager.GeolocationManagerClass
,GeolocationPermissionRequest.GeolocationPermissionRequestClass
,GLShader.GLShaderClass
,GutterLines.GutterLinesClass
,HitTestResult.HitTestResultClass
,HitTestResult.HitTestResultClass
,Hover.HoverClass
,HoverContext.HoverContextClass
,HSTSEnforcer.HSTSEnforcerClass
,IMContext.IMContextClass
,InetAddress.InetAddressClass
,InetAddressMask.InetAddressMaskClass
,InitiallyUnowned.InitiallyUnownedClass
,InputMethodContext.InputMethodContextClass
,InputStream.InputStreamClass
,IOStream.IOStreamClass
,Language.LanguageClass
,LanguageManager.LanguageManagerClass
,Layout.LayoutClass
,LayoutChild.LayoutChildClass
,LayoutManager.LayoutManagerClass
,LeafletPage.LeafletPageClass
,ListStore.ListStoreClass
,ListStore.ListStoreClass
,Logger.LoggerClass
,MapListModel.MapListModelClass
,MarkAttributes.MarkAttributesClass
,MediaKeySystemPermissionRequest.MediaKeySystemPermissionRequestClass
,MediaStream.MediaStreamClass
,MenuAttributeIter.MenuAttributeIterClass
,MenuLinkIter.MenuLinkIterClass
,MenuModel.MenuModelClass
,Message.MessageClass
,MountOperation.MountOperationClass
,MultiSelection.MultiSelectionClass
,NativeDialog.NativeDialogClass
,NetworkAddress.NetworkAddressClass
,NetworkService.NetworkServiceClass
,NetworkSession.NetworkSessionClass
,NoSelection.NoSelectionClass
,Notification.NotificationClass
,NotificationPermissionRequest.NotificationPermissionRequestClass
,OptionMenu.OptionMenuClass
,OsxAppInfo.OsxAppInfoClass
,OutputStream.OutputStreamClass
,Permission.PermissionClass
,PixbufAnimation.PixbufAnimationClass
,PixbufAnimationIter.PixbufAnimationIterClass
,PixbufLoader.PixbufLoaderClass
,PointerLockPermissionRequest.PointerLockPermissionRequestClass
,PolicyDecision.PolicyDecisionClass
,PrintCompositor.PrintCompositorClass
,PrintDialog.PrintDialogClass
,PrintOperation.PrintOperationClass
,PrintOperation.PrintOperationClass
,RecentManager.RecentManagerClass
,Region.RegionClass
,Renderer.RendererClass
,Resolver.ResolverClass
,ScriptWorld.ScriptWorldClass
,SearchContext.SearchContextClass
,SearchSettings.SearchSettingsClass
,SecurityManager.SecurityManagerClass
,SelectionFilterModel.SelectionFilterModelClass
,Server.ServerClass
,ServerMessage.ServerMessageClass
,Session.SessionClass
,Settings.SettingsClass
,Settings.SettingsClass
,SettingsBackend.SettingsBackendClass
,Shortcut.ShortcutClass
,SimpleActionGroup.SimpleActionGroupClass
,SimpleProxyResolver.SimpleProxyResolverClass
,SingleSelection.SingleSelectionClass
,SliceListModel.SliceListModelClass
,Snippet.SnippetClass
,SnippetContext.SnippetContextClass
,SnippetManager.SnippetManagerClass
,Socket.SocketClass
,SocketAddress.SocketAddressClass
,SocketAddressEnumerator.SocketAddressEnumeratorClass
,SocketClient.SocketClientClass
,SocketControlMessage.SocketControlMessageClass
,SocketListener.SocketListenerClass
,Sorter.SorterClass
,SortListModel.SortListModelClass
,SpaceDrawer.SpaceDrawerClass
,SpinnerPaintable.SpinnerPaintableClass
,SqueezerPage.SqueezerPageClass
,StringList.StringListClass
,StringObject.StringObjectClass
,Style.StyleClass
,StyleContext.StyleContextClass
,StyleManager.StyleManagerClass
,StyleScheme.StyleSchemeClass
,StyleSchemeManager.StyleSchemeManagerClass
,SwipeTracker.SwipeTrackerClass
,TabPage.TabPageClass
,TextBuffer.TextBufferClass
,TextChildAnchor.TextChildAnchorClass
,TextMark.TextMarkClass
,TextTag.TextTagClass
,TlsCertificate.TlsCertificateClass
,TlsDatabase.TlsDatabaseClass
,TlsInteraction.TlsInteractionClass
,TlsPassword.TlsPasswordClass
,Toast.ToastClass
,TreeListModel.TreeListModelClass
,TreeListRow.TreeListRowClass
,TreeModelFilter.TreeModelFilterClass
,TreeModelSort.TreeModelSortClass
,TreeStore.TreeStoreClass
,TypeModule.TypeModuleClass
,UnixFDList.UnixFDListClass
,UriLauncher.UriLauncherClass
,URIRequest.URIRequestClass
,URIRequest.URIRequestClass
,URIResponse.URIResponseClass
,URIResponse.URIResponseClass
,URISchemeRequest.URISchemeRequestClass
,URISchemeResponse.URISchemeResponseClass
,UserContentFilterStore.UserContentFilterStoreClass
,UserContentManager.UserContentManagerClass
,UserMediaPermissionRequest.UserMediaPermissionRequestClass
,Value.ValueClass
,Vfs.VfsClass
,ViewStackPage.ViewStackPageClass
,ViewStackPages.ViewStackPagesClass
,VirtualMachine.VirtualMachineClass
,VolumeMonitor.VolumeMonitorClass
,WeakValue.WeakValueClass
,WebContext.WebContextClass
,WebEditor.WebEditorClass
,WebFormManager.WebFormManagerClass
,WebHitTestResult.WebHitTestResultClass
,WebInspector.WebInspectorClass
,WebPage.WebPageClass
,WebProcessExtension.WebProcessExtensionClass
,WebResource.WebResourceClass
,WebsiteDataAccessPermissionRequest.WebsiteDataAccessPermissionRequestClass
,WebsiteDataManager.WebsiteDataManagerClass
,WebsitePolicies.WebsitePoliciesClass
,WebsocketConnection.WebsocketConnectionClass
,WebsocketExtension.WebsocketExtensionClass
,WebsocketExtensionManager.WebsocketExtensionManagerClass
,WidgetPaintable.WidgetPaintableClass
,WindowGroup.WindowGroupClass
,WindowProperties.WindowPropertiesClass
,ZlibCompressor.ZlibCompressorClass
,ZlibDecompressor.ZlibDecompressorClass
- Enclosing class:
GObject
// Example of implementing a singleton using a constructor.
static MySingleton *the_singleton = NULL;
static GObject*
my_singleton_constructor (GType type,
guint n_construct_params,
GObjectConstructParam *construct_params)
{
GObject *object;
if (!the_singleton)
{
object = G_OBJECT_CLASS (parent_class)->constructor (type,
n_construct_params,
construct_params);
the_singleton = MY_SINGLETON (object);
}
else
object = g_object_ref (G_OBJECT (the_singleton));
return object;
}
-
Constructor Summary
ConstructorDescriptionAllocate a new ObjectClass.ObjectClass
(Arena arena) Allocate a new ObjectClass.ObjectClass
(MemorySegment address) Create a ObjectClass proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionfindProperty
(String propertyName) Looks up theGParamSpec
for a property of a class.static MemoryLayout
The memory layout of the native struct.void
installProperties
(ParamSpec[] pspecs) Installs new properties from an array ofGParamSpecs
.void
installProperty
(int propertyId, ParamSpec pspec) Installs a new property.Get an array ofGParamSpec
* for all properties of a class.void
overrideConstructed
(Arena arena, Method method) Override virtual methodconstructed
.void
overrideConstructor
(Arena arena, Method method) Override virtual methodconstructor
.void
overrideDispatchPropertiesChanged
(Arena arena, Method method) Override virtual methoddispatch_properties_changed
.void
overrideDispose
(Arena arena, Method method) Override virtual methoddispose
.void
overrideFinalize
(Arena arena, Method method) Override virtual methodfinalize
.void
overrideGetProperty
(Arena arena, Method method) Override virtual methodget_property
.void
overrideNotify
(Arena arena, Method method) Override virtual methodnotify
.void
overrideProperty
(int propertyId, String name) RegisterspropertyId
as referring to a property with the namename
in a parent class or in an interface implemented by this ObjectClass.void
overrideSetProperty
(Arena arena, Method method) Override virtual methodset_property
.long
Read the value of the fieldflags
.long
Read the value of the fieldn_construct_properties
.long
Read the value of the fieldn_pspecs
.Read the value of the fieldpdummy
.Read the value of the fieldpspecs
.void
writeFlags
(long flags) Write a value in the fieldflags
.void
writeNConstructProperties
(long nConstructProperties) Write a value in the fieldn_construct_properties
.void
writeNPspecs
(long nPspecs) Write a value in the fieldn_pspecs
.void
writePdummy
(MemorySegment[] pdummy, Arena _arena) Write a value in the fieldpdummy
.void
writePspecs
(MemorySegment pspecs) Write a value in the fieldpspecs
.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
-
ObjectClass
Create a ObjectClass proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
ObjectClass
Allocate a new ObjectClass.- Parameters:
arena
- to control the memory allocation scope
-
ObjectClass
public ObjectClass()Allocate a new ObjectClass. The memory is allocated withArena.ofAuto()
.
-
-
Method Details
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
overrideConstructor
-
overrideSetProperty
-
overrideGetProperty
-
overrideDispose
-
overrideFinalize
-
overrideDispatchPropertiesChanged
-
overrideNotify
-
overrideConstructed
-
readFlags
public long readFlags()Read the value of the fieldflags
.- Returns:
- The value of the field
flags
-
writeFlags
public void writeFlags(long flags) Write a value in the fieldflags
.- Parameters:
flags
- The new value for the fieldflags
-
readNConstructProperties
public long readNConstructProperties()Read the value of the fieldn_construct_properties
.- Returns:
- The value of the field
n_construct_properties
-
writeNConstructProperties
public void writeNConstructProperties(long nConstructProperties) Write a value in the fieldn_construct_properties
.- Parameters:
nConstructProperties
- The new value for the fieldn_construct_properties
-
readPspecs
Read the value of the fieldpspecs
.- Returns:
- The value of the field
pspecs
-
writePspecs
Write a value in the fieldpspecs
.- Parameters:
pspecs
- The new value for the fieldpspecs
-
readNPspecs
public long readNPspecs()Read the value of the fieldn_pspecs
.- Returns:
- The value of the field
n_pspecs
-
writeNPspecs
public void writeNPspecs(long nPspecs) Write a value in the fieldn_pspecs
.- Parameters:
nPspecs
- The new value for the fieldn_pspecs
-
readPdummy
Read the value of the fieldpdummy
.- Returns:
- The value of the field
pdummy
-
writePdummy
Write a value in the fieldpdummy
.- Parameters:
pdummy
- The new value for the fieldpdummy
_arena
- to control the memory allocation scope
-
findProperty
-
installProperties
Installs new properties from an array ofGParamSpecs
.All properties should be installed during the class initializer. It is possible to install properties after that, but doing so is not recommend, and specifically, is not guaranteed to be thread-safe vs. use of properties on the same type on other threads.
The property id of each property is the index of each
GParamSpec
in thepspecs
array.The property id of 0 is treated specially by
GObject
and it should not be used to store aGParamSpec
.This function should be used if you plan to use a static array of
GParamSpecs
and g_object_notify_by_pspec(). For instance, this class initialization:typedef enum { PROP_FOO = 1, PROP_BAR, N_PROPERTIES } MyObjectProperty; static GParamSpec *obj_properties[N_PROPERTIES] = { NULL, }; static void my_object_class_init (MyObjectClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); obj_properties[PROP_FOO] = g_param_spec_int ("foo", NULL, NULL, -1, G_MAXINT, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); obj_properties[PROP_BAR] = g_param_spec_string ("bar", NULL, NULL, NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); gobject_class->set_property = my_object_set_property; gobject_class->get_property = my_object_get_property; g_object_class_install_properties (gobject_class, G_N_ELEMENTS (obj_properties), obj_properties); }
allows calling g_object_notify_by_pspec() to notify of property changes:
void my_object_set_foo (MyObject *self, gint foo) { if (self->foo != foo) { self->foo = foo; g_object_notify_by_pspec (G_OBJECT (self), obj_properties[PROP_FOO]); } }
- Parameters:
pspecs
- theGParamSpecs
array defining the new properties
-
installProperty
Installs a new property.All properties should be installed during the class initializer. It is possible to install properties after that, but doing so is not recommend, and specifically, is not guaranteed to be thread-safe vs. use of properties on the same type on other threads.
Note that it is possible to redefine a property in a derived class, by installing a property with the same name. This can be useful at times, e.g. to change the range of allowed values or the default value.
- Parameters:
propertyId
- the id for the new propertypspec
- theGParamSpec
for the new property
-
listProperties
Get an array ofGParamSpec
* for all properties of a class.- Returns:
- an array of
GParamSpec
* which should be freed after use
-
overrideProperty
RegisterspropertyId
as referring to a property with the namename
in a parent class or in an interface implemented by this ObjectClass. This allows this class to "override" a property implementation in a parent class or to provide the implementation of a property from an interface.Internally, overriding is implemented by creating a property of type
GParamSpecOverride
; generally operations that query the properties of the object class, such as g_object_class_find_property() or g_object_class_list_properties() will return the overridden property. However, in one case, theconstructProperties
argument of theconstructor
virtual function, theGParamSpecOverride
is passed instead, so that theparamId
field of theGParamSpec
will be correct. For virtually all uses, this makes no difference. If you need to get the overridden property, you can call g_param_spec_get_redirect_target().- Parameters:
propertyId
- the new property IDname
- the name of a property registered in a parent class or in an interface of this class.
-