[]Trait gtk::subclass::prelude::ObjectSubclass

pub trait ObjectSubclass: 'static + ObjectImpl where
    <Self::Instance as InstanceStruct>::Type == Self,
    <Self::Class as ClassStruct>::Type == Self, 
{ type ParentType: ObjectType + FromGlibPtrNone<*mut <Self::ParentType as ObjectType>::GlibType> + FromGlibPtrFull<*mut <Self::ParentType as ObjectType>::GlibType> + FromGlibPtrBorrow<*mut <Self::ParentType as ObjectType>::GlibType>; type Instance: InstanceStruct; type Class: ClassStruct; const NAME: &'static str; const ABSTRACT: bool; fn type_data() -> NonNull<TypeData>;
fn get_type() -> Type; fn get_instance(&self) -> Self::ParentType { ... }
fn from_instance<T>(obj: &T) -> &Self
    where
        T: IsA<Object>
, { ... }
fn type_init(_type_: &mut InitializingType<Self>) { ... }
fn class_init(_klass: &mut Self::Class) { ... }
fn new() -> Self { ... }
fn with_class(_klass: &Self::Class) -> Self { ... } }

The central trait for subclassing a GObject type.

Links together the type name, parent type and the instance and class structs for type registration and allows subclasses to hook into various steps of the type registration and initialization.

See register_type for registering an implementation of this trait with the type system.

Associated Types

type ParentType: ObjectType + FromGlibPtrNone<*mut <Self::ParentType as ObjectType>::GlibType> + FromGlibPtrFull<*mut <Self::ParentType as ObjectType>::GlibType> + FromGlibPtrBorrow<*mut <Self::ParentType as ObjectType>::GlibType>

Parent Rust type to inherit from.

type Instance: InstanceStruct

The C instance struct.

See simple::InstanceStruct for an basic instance struct that should be used in most cases.

type Class: ClassStruct

The C class struct.

See simple::ClassStruct for an basic instance struct that should be used in most cases.

Loading content...

Associated Constants

const NAME: &'static str

GObject type name.

This must be unique in the whole process.

const ABSTRACT: bool

If this subclass is an abstract class or not.

By default all subclasses are non-abstract types but setting this to true will create an abstract class instead.

Abstract classes can't be instantiated and require a non-abstract subclass.

Optional.

Loading content...

Required methods

fn type_data() -> NonNull<TypeData>

Storage for the type-specific data used during registration.

This is usually generated by the glib_object_subclass! macro.

fn get_type() -> Type

Returns the glib::Type ID of the subclass.

This will register the type with the type system on the first call and is usually generated by the glib_object_subclass! macro.

Loading content...

Provided methods

fn get_instance(&self) -> Self::ParentType

Returns the corresponding object instance.

fn from_instance<T>(obj: &T) -> &Self where
    T: IsA<Object>, 

Returns the implementation from an instance.

Panics if called on an object of the wrong type.

fn type_init(_type_: &mut InitializingType<Self>)

Additional type initialization.

This is called right after the type was registered and allows subclasses to do additional type-specific initialization, e.g. for implementing GObject interfaces.

Optional

fn class_init(_klass: &mut Self::Class)

Class initialization.

This is called after type_init and before the first instance of the subclass is created. Subclasses can use this to do class- specific initialization, e.g. for installing properties or signals on the class or calling class methods.

Optional

fn new() -> Self

Constructor.

This is called during object instantiation before further subclasses are initialized, and should return a new instance of the subclass private struct.

Optional, either implement this or with_class().

fn with_class(_klass: &Self::Class) -> Self

Constructor.

This is called during object instantiation before further subclasses are initialized, and should return a new instance of the subclass private struct.

Different to new() above it also gets the class of this type passed to itself for providing additional context.

Optional, either implement this or new().

Loading content...

Implementors

Loading content...