Class GObject.ObjectClass

All Implemented Interfaces:
Proxy
Direct Known Subclasses:
AccessibleHyperlink.AccessibleHyperlinkClass, AlertDialog.AlertDialogClass, Annotation.AnnotationClass, AnnotationProvider.AnnotationProviderClass, Annotations.AnnotationsClass, 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, DeviceInfoPermissionRequest.DeviceInfoPermissionRequestClass, DirectoryList.DirectoryListClass, Discoverer.DiscovererClass, DiscovererAudioInfoClass, DiscovererContainerInfoClass, DiscovererInfoClass, DiscovererStreamInfoClass, DiscovererSubtitleInfoClass, DiscovererVideoInfoClass, Download.DownloadClass, EditorState.EditorStateClass, EmblemedIcon.EmblemedIconClass, EncodingTargetClass, 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, Handle.HandleClass, HitTestResult.HitTestResultClass, HitTestResult.HitTestResultClass, Hover.HoverClass, HoverContext.HoverContextClass, HSTSEnforcer.HSTSEnforcerClass, IconPaintable.IconPaintableClass, 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, ShortcutsItem.ShortcutsItemClass, ShortcutsSection.ShortcutsSectionClass, SidebarItem.SidebarItemClass, SidebarSection.SidebarSectionClass, 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, Svg.SvgClass, SwipeTracker.SwipeTrackerClass, TabPage.TabPageClass, TextBuffer.TextBufferClass, TextChildAnchor.TextChildAnchorClass, TextMark.TextMarkClass, TextTag.TextTagClass, TlsCertificate.TlsCertificateClass, TlsDatabase.TlsDatabaseClass, TlsInteraction.TlsInteractionClass, TlsPassword.TlsPasswordClass, Toast.ToastClass, Toggle.ToggleClass, 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, WebExtension.WebExtensionClass, 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, XRPermissionRequest.XRPermissionRequestClass, ZlibCompressor.ZlibCompressorClass, ZlibDecompressor.ZlibDecompressorClass
Enclosing class:
GObject

public static class GObject.ObjectClass extends TypeClass

The class structure for the GObject type.

// 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 Details

    • ObjectClass

      public ObjectClass(MemorySegment address)
      Create a ObjectClass 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
    • readConstructProperties

      public SList<MemorySegment> readConstructProperties()
      Read the value of the field construct_properties.
      Returns:
      The value of the field construct_properties
    • writeConstructProperties

      public void writeConstructProperties(SList<MemorySegment> constructProperties)
      Write a value in the field construct_properties.
      Parameters:
      constructProperties - The new value for the field construct_properties
    • overrideConstructor

      public void overrideConstructor(Arena arena, @Nullable Method method)
      Override virtual method constructor.
      Parameters:
      method - the method to invoke
    • overrideSetProperty

      public void overrideSetProperty(Arena arena, @Nullable Method method)
      Override virtual method set_property.
      Parameters:
      method - the method to invoke
    • overrideGetProperty

      public void overrideGetProperty(Arena arena, @Nullable Method method)
      Override virtual method get_property.
      Parameters:
      method - the method to invoke
    • overrideDispose

      public void overrideDispose(Arena arena, @Nullable Method method)
      Override virtual method dispose.
      Parameters:
      method - the method to invoke
    • overrideFinalize

      public void overrideFinalize(Arena arena, @Nullable Method method)
      Override virtual method finalize.
      Parameters:
      method - the method to invoke
    • overrideDispatchPropertiesChanged

      public void overrideDispatchPropertiesChanged(Arena arena, @Nullable Method method)
      Override virtual method dispatch_properties_changed.
      Parameters:
      method - the method to invoke
    • overrideNotify

      public void overrideNotify(Arena arena, @Nullable Method method)
      Override virtual method notify.
      Parameters:
      method - the method to invoke
    • overrideConstructed

      public void overrideConstructed(Arena arena, @Nullable Method method)
      Override virtual method constructed.
      Parameters:
      method - the method to invoke
    • readFlags

      public long readFlags()
      Read the value of the field flags.
      Returns:
      The value of the field flags
    • writeFlags

      public void writeFlags(long flags)
      Write a value in the field flags.
      Parameters:
      flags - The new value for the field flags
    • readNConstructProperties

      public long readNConstructProperties()
      Read the value of the field n_construct_properties.
      Returns:
      The value of the field n_construct_properties
    • writeNConstructProperties

      public void writeNConstructProperties(long nConstructProperties)
      Write a value in the field n_construct_properties.
      Parameters:
      nConstructProperties - The new value for the field n_construct_properties
    • readPspecs

      public MemorySegment readPspecs()
      Read the value of the field pspecs.
      Returns:
      The value of the field pspecs
    • writePspecs

      public void writePspecs(MemorySegment pspecs)
      Write a value in the field pspecs.
      Parameters:
      pspecs - The new value for the field pspecs
    • readNPspecs

      public long readNPspecs()
      Read the value of the field n_pspecs.
      Returns:
      The value of the field n_pspecs
    • writeNPspecs

      public void writeNPspecs(long nPspecs)
      Write a value in the field n_pspecs.
      Parameters:
      nPspecs - The new value for the field n_pspecs
    • readPdummy

      public @Nullable MemorySegment @Nullable [] readPdummy()
      Read the value of the field pdummy.
      Returns:
      The value of the field pdummy
    • writePdummy

      public void writePdummy(@Nullable MemorySegment @Nullable [] pdummy, Arena _arena)
      Write a value in the field pdummy.
      Parameters:
      pdummy - The new value for the field pdummy
    • findProperty

      public ParamSpec findProperty(String propertyName)
      Looks up the GParamSpec for a property of a class.
      Parameters:
      propertyName - the name of the property to look up
      Returns:
      the GParamSpec for the property, or null if the class doesn't have a property of that name
    • installProperties

      public void installProperties(@Nullable ParamSpec @Nullable [] pspecs)

      Installs new properties from an array of GParamSpecs.

      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 the pspecs array.

      The property id of 0 is treated specially by GObject and it should not be used to store a GParamSpec.

      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 - the GParamSpecs array defining the new properties
      Since:
      2.26
    • installProperty

      public void installProperty(int propertyId, ParamSpec pspec)

      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 property
      pspec - the GParamSpec for the new property
    • listProperties

      public ParamSpec[] listProperties()
      Get an array of GParamSpec* for all properties of a class.
      Returns:
      an array of GParamSpec* which should be freed after use
    • overrideProperty

      public void overrideProperty(int propertyId, String name)

      Registers propertyId as referring to a property with the name name in a parent class or in an interface implemented by oclass. 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, the constructProperties argument of the constructor virtual function, the GParamSpecOverride is passed instead, so that the paramId field of the GParamSpec 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 ID
      name - the name of a property registered in a parent class or in an interface of this class.
      Since:
      2.4