Documentation ¶
Overview ¶
Package glib provides some hand-written GObject and GLib bindings.
Index ¶
- Constants
- Variables
- func CastObject(obj *Object) interface{}deprecated
- func ConnectedGeneratedClosure(closureData uintptr) *closure.FuncStack
- func Destroy(objector Objector)
- func InitI18n(domain, dir string)
- func Local(input string) string
- func NewClosure(v *Object, f interface{}) unsafe.Pointer
- func ObjectEq(obj1, obj2 Objector) bool
- func Overrides[OverridesT any](obj Objector) OverridesT
- func OverridesFromObj[OverridesT any](obj *Object) OverridesT
- func ParentOverrides[OverridesT any](obj Objector) OverridesT
- func PeekParentClass(obj Objector) unsafe.Pointer
- func RegisterClassInfo[InstanceT Objector, ClassT, OverridesT any](gtype Type, ...)
- func RegisterGValueMarshaler(t Type, f GValueMarshaler)
- func RegisterGValueMarshalers(marshalers []TypeMarshaler)
- func SourceRemove(src SourceHandle) bool
- func VariantTypeStringIsValid(typeString string) bool
- func WeakRefObject(obj Objector, notify func())
- func WipeAllClosures(objector Objector)deprecated
- type AnyClosure
- type GValueMarshaler
- type GeneratedClosuredeprecated
- type InitiallyUnowned
- type Object
- func (v *Object) Cast() Objector
- func (v *Object) CastType(gtype Type) Objector
- func (v *Object) Connect(detailedSignal string, f interface{}) SignalHandle
- func (v *Object) ConnectAfter(detailedSignal string, f interface{}) SignalHandle
- func (v *Object) Emit(s string, args ...interface{}) interface{}
- func (v *Object) Eq(other Objector) bool
- func (v *Object) FreezeNotify()
- func (v *Object) HandlerBlock(handle SignalHandle)
- func (v *Object) HandlerDisconnect(handle SignalHandle)
- func (v *Object) HandlerUnblock(handle SignalHandle)
- func (v *Object) IsA(typ Type) bool
- func (v *Object) Native() uintptr
- func (v *Object) NotifyProperty(property string, f func()) SignalHandle
- func (v *Object) ObjectProperty(name string) interface{}
- func (v *Object) PropertyType(name string) Type
- func (v *Object) SetObjectProperty(name string, value interface{})
- func (v *Object) StopEmission(s string)
- func (v *Object) ThawNotify()
- func (v *Object) Type() Type
- func (v *Object) TypeFromInstance() Type
- func (v *Object) WalkCast(f func(Objector) bool) (object Objector)
- type ObjectOverrides
- type Objector
- type ParamFlags
- type ParamSpec
- func NewBoolParam(name, nick, blurb string, defaultValue bool, flags ParamFlags) *ParamSpec
- func NewBoxedParam(name, nick, blurb string, boxedType Type, flags ParamFlags) *ParamSpec
- func NewFloat32Param(name, nick, blurb string, min, max, defaultValue float32, flags ParamFlags) *ParamSpec
- func NewFloat64Param(name, nick, blurb string, min, max, defaultValue float64, flags ParamFlags) *ParamSpec
- func NewInt64Param(name, nick, blurb string, min, max, defaultValue int64, flags ParamFlags) *ParamSpec
- func NewIntParam(name, nick, blurb string, min, max, defaultValue int32, flags ParamFlags) *ParamSpec
- func NewStringParam(name, nick, blurb string, defaultValue string, flags ParamFlags) *ParamSpec
- func NewUint64Param(name, nick, blurb string, min, max, defaultValue uint64, flags ParamFlags) *ParamSpec
- func NewUintParam(name, nick, blurb string, min, max, defaultValue uint32, flags ParamFlags) *ParamSpec
- func ParamSpecFromNative(ptr unsafe.Pointer) *ParamSpec
- func ParamSpecTake(ptr unsafe.Pointer, take bool) *ParamSpec
- type Priority
- type Property
- type RegisterOptsFunc
- type RegisteredSubclass
- type SList
- func (v *SList) Append(data uintptr) *SList
- func (v *SList) Data() interface{}
- func (v *SList) DataRaw() unsafe.Pointer
- func (v *SList) DataWrapper(fn func(unsafe.Pointer) interface{})
- func (v *SList) Foreach(fn func(item interface{}))
- func (v *SList) Free()
- func (v *SList) FreeFull()
- func (v *SList) Length() uint
- func (v *SList) Native() uintptr
- func (v *SList) Next() *SList
- type SignalHandle
- type SourceHandle
- func IdleAdd(f interface{}) SourceHandle
- func IdleAddPriority(priority Priority, f interface{}) SourceHandle
- func TimeoutAdd(milliseconds uint, f interface{}) SourceHandle
- func TimeoutAddPriority(milliseconds uint, priority Priority, f interface{}) SourceHandle
- func TimeoutSecondsAdd(seconds uint, f interface{}) SourceHandle
- func TimeoutSecondsAddPriority(seconds uint, priority Priority, f interface{}) SourceHandle
- type Type
- type TypeMarshaler
- type Value
- func (v *Value) Boxed() unsafe.Pointer
- func (v *Value) Enum() int
- func (v *Value) Flags() uint
- func (v *Value) GoValue() interface{}
- func (v *Value) GoValueAsType(gtype Type) interface{}
- func (v *Value) Init(gtype Type)
- func (v *Value) InitGoValue(goValue any)
- func (v *Value) IsValue() bool
- func (v *Value) Native() uintptr
- func (v *Value) Object() *Object
- func (v *Value) Pointer() unsafe.Pointer
- func (v *Value) SetBool(val bool)
- func (v *Value) SetDouble(val float64)
- func (v *Value) SetFloat(val float32)
- func (v *Value) SetInstance(instance uintptr)
- func (v *Value) SetInt(val int)
- func (v *Value) SetInt64(val int64)
- func (v *Value) SetLong(long int32)
- func (v *Value) SetObject(obj *Object)
- func (v *Value) SetPointer(p uintptr)
- func (v *Value) SetSchar(val int8)
- func (v *Value) SetString(val string)
- func (v *Value) SetUchar(val uint8)
- func (v *Value) SetUint(val uint)
- func (v *Value) SetUint64(val uint64)
- func (v *Value) SetUlong(ulong uint32)
- func (v *Value) String() string
- func (v *Value) Type() (actual Type)
- func (v *Value) TypeName() string
- func (v *Value) WalkGoValue(f func(interface{}) bool) (value interface{})
- type Variant
- func (v *Variant) GoValue() interface{}
- func (v *Variant) IsContainer() bool
- func (v *Variant) IsFloating() bool
- func (v *Variant) IsType(t *VariantType) bool
- func (v *Variant) Native() uintptr
- func (v *Variant) Print(typeAnnotate bool) string
- func (v *Variant) Ref()
- func (v *Variant) RefSink()
- func (v *Variant) String() string
- func (v *Variant) TakeRef()
- func (v *Variant) Type() *VariantType
- func (v *Variant) TypeString() string
- func (v *Variant) Unref()
- type VariantType
- type WeakRef
Constants ¶
const ( ParamReadable ParamFlags = C.G_PARAM_READABLE ParamWritable = C.G_PARAM_WRITABLE ParamReadWrite = C.G_PARAM_READABLE | C.G_PARAM_WRITABLE ParamConstruct = C.G_PARAM_CONSTRUCT ParamConstructOnly = C.G_PARAM_CONSTRUCT_ONLY ParamLaxValidation = C.G_PARAM_LAX_VALIDATION ParamStaticName = C.G_PARAM_STATIC_NAME ParamStaticNick = C.G_PARAM_STATIC_NICK ParamStaticBlurb = C.G_PARAM_STATIC_BLURB ParamExplicitNotify = C.G_PARAM_EXPLICIT_NOTIFY ParamDeprecated = C.G_PARAM_DEPRECATED )
Variables ¶
var ( VariantTypeBoolean = newVariantType(C.G_VARIANT_TYPE_BOOLEAN) VariantTypeByte = newVariantType(C.G_VARIANT_TYPE_BYTE) VariantTypeInt16 = newVariantType(C.G_VARIANT_TYPE_INT16) VariantTypeUint16 = newVariantType(C.G_VARIANT_TYPE_UINT16) VariantTypeInt32 = newVariantType(C.G_VARIANT_TYPE_INT32) VariantTypeUint32 = newVariantType(C.G_VARIANT_TYPE_UINT32) VariantTypeInt64 = newVariantType(C.G_VARIANT_TYPE_INT64) VariantTypeUint64 = newVariantType(C.G_VARIANT_TYPE_UINT64) VariantTypeHandle = newVariantType(C.G_VARIANT_TYPE_HANDLE) VariantTypeDouble = newVariantType(C.G_VARIANT_TYPE_DOUBLE) VariantTypeString = newVariantType(C.G_VARIANT_TYPE_STRING) VariantTypeObjectPath = newVariantType(C.G_VARIANT_TYPE_OBJECT_PATH) VariantTypeSignature = newVariantType(C.G_VARIANT_TYPE_SIGNATURE) VariantTypeVariant = newVariantType(C.G_VARIANT_TYPE_VARIANT) VariantTypeAny = newVariantType(C.G_VARIANT_TYPE_ANY) VariantTypeBasic = newVariantType(C.G_VARIANT_TYPE_BASIC) VariantTypeMaybe = newVariantType(C.G_VARIANT_TYPE_MAYBE) VariantTypeArray = newVariantType(C.G_VARIANT_TYPE_ARRAY) VariantTypeTuple = newVariantType(C.G_VARIANT_TYPE_TUPLE) VariantTypeUnit = newVariantType(C.G_VARIANT_TYPE_UNIT) VariantTypeDictEntry = newVariantType(C.G_VARIANT_TYPE_DICT_ENTRY) VariantTypeDictionary = newVariantType(C.G_VARIANT_TYPE_DICTIONARY) VariantTypeStringArray = newVariantType(C.G_VARIANT_TYPE_STRING_ARRAY) VariantTypeObjectPathArray = newVariantType(C.G_VARIANT_TYPE_OBJECT_PATH_ARRAY) VariantTypeBytestring = newVariantType(C.G_VARIANT_TYPE_BYTESTRING) VariantTypeBytestringArray = newVariantType(C.G_VARIANT_TYPE_BYTESTRING_ARRAY) VariantTypeVardict = newVariantType(C.G_VARIANT_TYPE_VARDICT) )
Variant types for comparison. Note that variant types cannot be compared by value; use VariantType.Equal instead.
var ( // InvalidValue is returned from Value methods, such as GoValue, to indicate // that the value obtained is invalid. InvalidValue = invalidValueType{} )
Functions ¶
func CastObject
deprecated
func CastObject(obj *Object) interface{}
CastObject casts the given object pointer to the Go concrete type. The caller is responsible for recasting the interface to the wanted type.
Deprecated: Use obj.Cast() instead.
func ConnectedGeneratedClosure ¶
ConnectedGeneratedClosure returns the function from the given user_data pointer that's set by ConnectGeneratedClosure's GClosure instance.
func Destroy ¶
func Destroy(objector Objector)
Destroy destroys the Go reference to the given object. The object must not be used ever again; it is the caller's responsibility to ensure that it will never be used again. Resurrecting the object again is undefined behavior.
func InitI18n ¶
func InitI18n(domain, dir string)
InitI18n initializes the i18n subsystem. It runs the following C code:
setlocale(LC_ALL, ""); bindtextdomain(domain, dir); bind_textdomain_codeset(domain, "UTF-8"); textdomain(domain);
func NewClosure ¶
NewClosure creates a new closure for the given object.
func Overrides ¶ added in v0.0.5
Overrides gets the XOverrides instance associated with the given object's parent. The instance will have already been modified by the subclass if it did.
func OverridesFromObj ¶ added in v0.0.5
OverridesFromObj is like Overrides, except it specifically takes the base object. The GType is asked for instead of using the underlying Go type.
func ParentOverrides ¶ added in v0.0.5
ParentOverrides is similar to Overrides, except the object's parent type is used instead of the object's type.
func PeekParentClass ¶ added in v0.0.5
PeekParentClass returns the C.TClass type using peek_parent, which is free of any subclassing changes.
func RegisterClassInfo ¶ added in v0.0.5
func RegisterClassInfo[InstanceT Objector, ClassT, OverridesT any]( gtype Type, initClassFunc func(gclass unsafe.Pointer, overrides OverridesT, initFunc func(ClassT)), wrapClassFunc func(*Object) InstanceT, overridesFunc func(InstanceT) OverridesT, )
RegisterClassInfo registers the given class type info. This function is NOT thread-safe; only call it in init().
func RegisterGValueMarshaler ¶
func RegisterGValueMarshaler(t Type, f GValueMarshaler)
RegisterGValueMarshaler registers a single GValue marshaler. If the function has already been called before on the same Type, then it does nothing, and the new function is ignored.
func RegisterGValueMarshalers ¶
func RegisterGValueMarshalers(marshalers []TypeMarshaler)
RegisterGValueMarshalers adds marshalers for several types to the internal marshalers map. Once registered, calling GoValue on any Value with a registered type will return the data returned by the marshaler.
func SourceRemove ¶
func SourceRemove(src SourceHandle) bool
SourceRemove is a wrapper around g_source_remove()
func VariantTypeStringIsValid ¶
VariantTypeStringIsValid is a wrapper around g_variant_type_string_is_valid.
func WeakRefObject ¶
func WeakRefObject(obj Objector, notify func())
WeakRefObject is like SetFinalizer, except it's not thread-safe (so notify SHOULD NOT REFERENCE OBJECT). It is best that you just do not use this at all.
func WipeAllClosures
deprecated
func WipeAllClosures(objector Objector)
WipeAllClosures wipes all the Go closures associated with the given object away. BE EXTREMELY CAREFUL WHEN USING THIS FUNCTION! If not careful, your program WILL crash!
There is only one specific use case for this function: if your object has closures connected to it where these closures capture the object itself, then it might create a cyclic dependency on the GC, preventing its finalizer from ever running. This will cause the program to leak memory. As a temporary hack, this function is introduced for cases where the programmer knows for sure that the object will never be used again, and it is significant enough of a leak that having a workaround is better than not.
Deprecated: this function is dangerous and should not be used. Using this function now causes a panic.
Types ¶
type AnyClosure ¶
type AnyClosure interface{}
AnyClosure describes any function type. If AnyClosure does not contain a function type, the consumer function is allowed to panic.
type GValueMarshaler ¶
GValueMarshaler is a marshal function to convert a GValue into an appropriate Go type. The uintptr parameter is a *C.GValue.
type GeneratedClosure
deprecated
type GeneratedClosure struct {
Func interface{}
}
GeneratedClosure boxes around any function value to be given to FuncStack.
The user should never use this struct. The code generator should use it like so:
obj.Connect("signal", externglib.GeneratedClosure{Func: v})
There are a few differences in behavior that we have to make in goMarshal(), and we want a clean way to differentiate manual Connect() calls with traditional closures and autogenerated ones that are far more consistent.
Deprecated: this isn't used anywhere anymore.
type InitiallyUnowned ¶
type InitiallyUnowned struct {
*Object
}
InitiallyUnowned is a representation of GLib's GInitiallyUnowned.
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
Object is a representation of GLib's GObject. Object types cannot be compared; pointer comparisons must be done using the Eq method.
func AssumeOwnership ¶
AssumeOwnership is similar to Take, except the function does not take a reference. This is usually used for newly constructed objects that for some reason does not have an initial floating reference.
To be clear, this should often be used when Gtk says "transfer full", as it means the ownership is transferred to us (Go), so we can assume that much. This is in contrary to Take, which is used when Gtk says "transfer none", as we're now referencing an object that might possibly be kept by C, so we should take our own.
func BaseObject ¶
BaseObject gets the internal Object type. This is used for calling methods not in the Objector.
func InternObject
deprecated
func Take ¶
Take wraps a unsafe.Pointer as a Object, taking ownership of it. This function is exported for visibility in other gotk3 packages and is not meant to be used by applications.
To be clear, this should mostly be used when Gtk says "transfer none". Refer to AssumeOwnership for more details.
func (*Object) CastType ¶ added in v0.0.5
CastType casts v to a concrete Go type that is associated with the given GType.
func (*Object) Connect ¶
func (v *Object) Connect(detailedSignal string, f interface{}) SignalHandle
Connect is a wrapper around g_signal_connect_closure(). f must be a function with at least one parameter matching the type it is connected to.
It is optional to list the rest of the required types from GTK, as values that don't fit into the function parameter will simply be ignored; however, extraneous types will trigger a runtime panic. Arguments for f must be a matching Go equivalent type for the C callback, or an interface type which the value may be packed in. If the type is not suitable, a runtime panic will occur when the signal is emitted.
func (*Object) ConnectAfter ¶
func (v *Object) ConnectAfter(detailedSignal string, f interface{}) SignalHandle
ConnectAfter is a wrapper around g_signal_connect_closure(). The difference between Connect and ConnectAfter is that the latter will be invoked after the default handler, not before. For more information, refer to Connect.
func (*Object) Emit ¶
Emit emits the signal specified by the string s to an Object. Arguments to callback functions connected to this signal must be specified in args. Emit returns an interface{} which must be type asserted to an equivalent Go type. The return value is the return value for the native C callback.
Note that this code is unsafe in that the types of values in args are not checked against whether they are suitable for the callback.
func (*Object) FreezeNotify ¶ added in v0.2.0
func (v *Object) FreezeNotify()
FreezeNotify increases the freeze count on object. If the freeze count is non-zero, the emission of “notify” signals on object is stopped. The signals are queued until the freeze count is decreased to zero. Duplicate notifications are squashed so that at most one GObject::notify signal is emitted for each property modified while the object is frozen.
This is necessary for accessors that modify multiple properties to prevent premature notification while the object is still being modified.
func (*Object) HandlerBlock ¶
func (v *Object) HandlerBlock(handle SignalHandle)
HandlerBlock is a wrapper around g_signal_handler_block().
func (*Object) HandlerDisconnect ¶
func (v *Object) HandlerDisconnect(handle SignalHandle)
HandlerDisconnect is a wrapper around g_signal_handler_disconnect().
func (*Object) HandlerUnblock ¶
func (v *Object) HandlerUnblock(handle SignalHandle)
HandlerUnblock is a wrapper around g_signal_handler_unblock().
func (*Object) NotifyProperty ¶
func (v *Object) NotifyProperty(property string, f func()) SignalHandle
NotifyProperty adds a handler that's called when the object's property is updated.
func (*Object) ObjectProperty ¶
ObjectProperty is a wrapper around g_object_get_property(). If the property's type cannot be resolved to a Go type, then InvalidValue is returned.
func (*Object) PropertyType ¶
PropertyType returns the Type of a property of the underlying GObject. If the property is missing, it will return TypeInvalid.
func (*Object) SetObjectProperty ¶
SetObjectProperty is a wrapper around g_object_set_property().
func (*Object) StopEmission ¶
StopEmission stops a signal’s current emission. It is a wrapper around g_signal_stop_emission_by_name().
func (*Object) ThawNotify ¶ added in v0.2.0
func (v *Object) ThawNotify()
ThawNotify reverts the effect of a previous call to g_object_freeze_notify(). The freeze count is decreased on object and when it reaches zero, queued “notify” signals are emitted.
Duplicate notifications for each property are squashed so that at most one GObject::notify signal is emitted for each property, in the reverse order in which they have been queued.
It is an error to call this function when the freeze count is zero.
func (*Object) TypeFromInstance ¶
TypeFromInstance is a wrapper around g_type_from_instance().
type ObjectOverrides ¶ added in v0.0.5
type ObjectOverrides struct { // Init is called during init_instance, which is actually when a // GTypeInstance is instantiated, not GObject. Init func() // Dispose is called during GObject's dispose. Dispose func() }
ObjectOverrides contains optional virtual methods hookable onto the Object type.
type Objector ¶
type Objector interface { HandlerBlock(SignalHandle) HandlerUnblock(SignalHandle) HandlerDisconnect(SignalHandle) NotifyProperty(string, func()) SignalHandle ObjectProperty(string) interface{} SetObjectProperty(string, interface{}) FreezeNotify() ThawNotify() StopEmission(string) // contains filtered or unexported methods }
Objector is an interface that describes the Object type's methods. Only this package's Object types and types that embed it can satisfy this interface.
type ParamFlags ¶ added in v0.0.5
type ParamFlags int
ParamFlags is a go cast of GParamFlags.
func (ParamFlags) Has ¶ added in v0.0.5
func (p ParamFlags) Has(b ParamFlags) bool
Has returns true if these flags contain the provided ones.
type ParamSpec ¶ added in v0.0.5
type ParamSpec struct {
// contains filtered or unexported fields
}
ParamSpec is a go representation of a C GParamSpec
func NewBoolParam ¶ added in v0.0.5
func NewBoolParam(name, nick, blurb string, defaultValue bool, flags ParamFlags) *ParamSpec
NewBoolParam creates a new ParamSpec that will hold a boolean value.
func NewBoxedParam ¶ added in v0.0.5
func NewBoxedParam(name, nick, blurb string, boxedType Type, flags ParamFlags) *ParamSpec
NewBoxedParam creates a new ParamSpec containing a boxed type.
func NewFloat32Param ¶ added in v0.0.5
func NewFloat32Param(name, nick, blurb string, min, max, defaultValue float32, flags ParamFlags) *ParamSpec
NewFloat32Param creates a new ParamSpec that will hold a 32-bit float value.
func NewFloat64Param ¶ added in v0.0.5
func NewFloat64Param(name, nick, blurb string, min, max, defaultValue float64, flags ParamFlags) *ParamSpec
NewFloat64Param creates a new ParamSpec that will hold a 64-bit float value.
func NewInt64Param ¶ added in v0.0.5
func NewInt64Param(name, nick, blurb string, min, max, defaultValue int64, flags ParamFlags) *ParamSpec
NewInt64Param creates a new ParamSpec that will hold a signed 64-bit integer value.
func NewIntParam ¶ added in v0.0.5
func NewIntParam(name, nick, blurb string, min, max, defaultValue int32, flags ParamFlags) *ParamSpec
NewIntParam creates a new ParamSpec that will hold a signed integer value.
func NewStringParam ¶ added in v0.0.5
func NewStringParam(name, nick, blurb string, defaultValue string, flags ParamFlags) *ParamSpec
NewStringParam returns a new ParamSpec that will hold a string value.
func NewUint64Param ¶ added in v0.0.5
func NewUint64Param(name, nick, blurb string, min, max, defaultValue uint64, flags ParamFlags) *ParamSpec
NewUint64Param creates a new ParamSpec that will hold an unsigned 64-bit integer value.
func NewUintParam ¶ added in v0.0.5
func NewUintParam(name, nick, blurb string, min, max, defaultValue uint32, flags ParamFlags) *ParamSpec
NewUintParam creates a new ParamSpec that will hold an unsigned integer value.
func ParamSpecFromNative ¶ added in v0.0.5
ParamSpecFromNative wraps ptr into a ParamSpec.
func ParamSpecTake ¶ added in v0.0.5
ParamSpecTake wraps ptr into a ParamSpec and ensures that it's properly GC'd.
func (*ParamSpec) Flags ¶ added in v0.0.5
func (p *ParamSpec) Flags() ParamFlags
Flags returns the flags for this parameter.
func (*ParamSpec) OwnerType ¶ added in v0.0.5
OwnerType returns the Gtype for the owner of this parameter.
type Priority ¶
type Priority int
Priority is the enumerated type for GLib priority event sources.
const ( PriorityHigh Priority = C.G_PRIORITY_HIGH PriorityDefault Priority = C.G_PRIORITY_DEFAULT // TimeoutAdd PriorityHighIdle Priority = C.G_PRIORITY_HIGH_IDLE PriorityDefaultIdle Priority = C.G_PRIORITY_DEFAULT_IDLE // IdleAdd PriorityLow Priority = C.G_PRIORITY_LOW )
type Property ¶ added in v0.0.5
type Property[T any] struct { // contains filtered or unexported fields }
Property describes a Go GObject property. It is used as an alternative to manually written property getter/setters.
func (*Property[T]) Get ¶ added in v0.0.5
func (p *Property[T]) Get() T
Get gets the value of the property.
func (*Property[T]) Notify ¶ added in v0.0.5
func (p *Property[T]) Notify(f func(T)) SignalHandle
Notify calls f everytime the property changes.
type RegisterOptsFunc ¶ added in v0.0.5
type RegisterOptsFunc func(*registerOpts)
RegisterOptsFunc is a function type that modifies the behavior of a RegisterSubclass call.
func WithClassInit ¶ added in v0.0.5
func WithClassInit[ClassT any](f func(ClassT)) RegisterOptsFunc
WithClassInit adds a custom ClassInit function. Use this method to add a function that, for example, takes in a WidgetClass.
func WithGTypeName ¶ added in v0.0.5
func WithGTypeName(gtypeName string) RegisterOptsFunc
WithGTypeName overrides the autogenerated GLib type name, which is the namespace concatenated with the Go type name.
func WithOverrides ¶ added in v0.0.5
func WithOverrides[T Objector, OverridesT any](f func(T) OverridesT) RegisterOptsFunc
WithOverrides adds one XOverrides instance into the subclass. The user can use this to override any particular virtual method of any of its parent classes.
func WithParamSpecs ¶ added in v0.0.5
func WithParamSpecs(paramSpecs []*ParamSpec) RegisterOptsFunc
WithParamSpecs adds additional ParamSpecs into a type for its properties.
type RegisteredSubclass ¶ added in v0.0.5
type RegisteredSubclass[T any] registeredSubclass
RegisteredSubclass is a type that described a registered Go subclass type.
func RegisterSubclass ¶ added in v0.0.5
func RegisterSubclass[T Objector](opts ...RegisterOptsFunc) *RegisteredSubclass[T]
RegisterSubclass is RegisterSubclassWithConstructor, but a zero-value instance of T is automatically created.
func RegisterSubclassWithConstructor ¶ added in v0.0.5
func RegisterSubclassWithConstructor[T Objector](ctor func() T, opts ...RegisterOptsFunc) *RegisteredSubclass[T]
RegisterSubclassWithConstructor registers a new type T that is a subclass of its parent type, which is the first field that must be embedded.
ctor has to be idempotent (i.e. can be called multiple times w/o side effects).
func (*RegisteredSubclass[T]) New ¶ added in v0.0.5
func (r *RegisteredSubclass[T]) New() T
New creates an instance of the subclass object with no properties.
func (*RegisteredSubclass[T]) NewWithProperties ¶ added in v0.0.5
func (r *RegisteredSubclass[T]) NewWithProperties(properties map[string]any) T
NewWithProperties creates an instance of the subclass object with the given properties.
func (*RegisteredSubclass[T]) Type ¶ added in v0.0.5
func (r *RegisteredSubclass[T]) Type() Type
Type returns the GType of the registered Go subclass.
type SList ¶
type SList struct {
// contains filtered or unexported fields
}
SList is a representation of Glib's GSList. A SList must be manually freed by either calling Free() or FreeFull()
func (*SList) Data ¶
func (v *SList) Data() interface{}
Data acts the same as data struct field, but it returns raw unsafe.Pointer as interface. TODO: Align with List struct and add member + logic for `dataWrap func(unsafe.Pointer) interface{}`?
func (*SList) DataWrapper ¶
DataWapper sets wrap functions, which is called during NthData() and Data(). It's used to cast raw C data into appropriate Go structures and types every time that data is retreived.
func (*SList) Foreach ¶
func (v *SList) Foreach(fn func(item interface{}))
Foreach acts the same as g_slist_foreach(). No user_data argument is implemented because of Go clojure capabilities.
type SignalHandle ¶
type SignalHandle uint
SignalHandle is the ID of a signal handler.
func ConnectGeneratedClosure ¶
func ConnectGeneratedClosure( obj Objector, signal string, after bool, tramp unsafe.Pointer, f interface{}) SignalHandle
ConnectGeneratedClosure connects the exported trampoline function and a Go closure (in f) to the given signal.
type SourceHandle ¶
type SourceHandle uint
func IdleAdd ¶
func IdleAdd(f interface{}) SourceHandle
IdleAdd adds an idle source to the default main event loop context with the DefaultIdle priority. If f is not a function with no parameter, then IdleAdd will panic.
After running once, the source func will be removed from the main event loop, unless f returns a single bool true.
func IdleAddPriority ¶
func IdleAddPriority(priority Priority, f interface{}) SourceHandle
IdleAddPriority adds an idle source to the default main event loop context with the given priority. Its behavior is the same as IdleAdd.
func TimeoutAdd ¶
func TimeoutAdd(milliseconds uint, f interface{}) SourceHandle
TimeoutAdd adds an timeout source to the default main event loop context. Timeout is in milliseconds. If f is not a function with no parameter, then it will panic.
After running once, the source func will be removed from the main event loop, unless f returns a single bool true.
func TimeoutAddPriority ¶
func TimeoutAddPriority(milliseconds uint, priority Priority, f interface{}) SourceHandle
TimeoutAddPriority is similar to TimeoutAdd with the given priority. Refer to TimeoutAdd for more information.
func TimeoutSecondsAdd ¶
func TimeoutSecondsAdd(seconds uint, f interface{}) SourceHandle
TimeoutSecondsAdd is similar to TimeoutAdd, except with seconds granularity.
func TimeoutSecondsAddPriority ¶
func TimeoutSecondsAddPriority(seconds uint, priority Priority, f interface{}) SourceHandle
TimeoutSecondsAddPriority adds a timeout source with the given priority. Refer to TimeoutSecondsAdd for more information.
type Type ¶
type Type uint
Type is a representation of GLib's GType.
const ( TypeInvalid Type = C.G_TYPE_INVALID TypeNone Type = C.G_TYPE_NONE TypeInterface Type = C.G_TYPE_INTERFACE TypeChar Type = C.G_TYPE_CHAR TypeUchar Type = C.G_TYPE_UCHAR TypeBoolean Type = C.G_TYPE_BOOLEAN TypeInt Type = C.G_TYPE_INT TypeUint Type = C.G_TYPE_UINT TypeLong Type = C.G_TYPE_LONG TypeUlong Type = C.G_TYPE_ULONG TypeInt64 Type = C.G_TYPE_INT64 TypeUint64 Type = C.G_TYPE_UINT64 TypeEnum Type = C.G_TYPE_ENUM TypeFlags Type = C.G_TYPE_FLAGS TypeFloat Type = C.G_TYPE_FLOAT TypeDouble Type = C.G_TYPE_DOUBLE TypeString Type = C.G_TYPE_STRING TypePointer Type = C.G_TYPE_POINTER TypeBoxed Type = C.G_TYPE_BOXED TypeParam Type = C.G_TYPE_PARAM TypeObject Type = C.G_TYPE_OBJECT TypeVariant Type = C.G_TYPE_VARIANT )
func FundamentalType ¶
FundamentalType returns the fundamental type of the given actual type.
func TypeFromName ¶
TypeFromName is a wrapper around g_type_from_name().
func TypeNextBase ¶
TypeNextBase is a wrapper around g_type_next_base.
func (Type) Interfaces ¶
Interfaces returns the interfaces of the given type.
type TypeMarshaler ¶
type TypeMarshaler struct { T Type F GValueMarshaler }
TypeMarshaler represents an actual type and it's associated marshaler.
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Value is a representation of GLib's GValue.
func AllocateValue ¶
func AllocateValue() *Value
AllocateValue allocates a Value but does not initialize it. It sets a runtime finalizer to call g_value_unset() on the underlying GValue after leaving scope.
func InitValue ¶
InitValue is a wrapper around g_value_init() and allocates and initializes a new Value with the Type t. A runtime finalizer is set to call g_value_unset() on the underlying GValue after leaving scope. ValueInit() returns a non-nil error if the allocation failed.
func NewValue ¶
func NewValue(v interface{}) *Value
NewValue converts a Go type to a comparable GValue. It will panic if the given type is unknown. Most Go primitive types and all Object types are supported.
func ValueFromNative ¶
ValueFromNative returns a type-asserted pointer to the Value. It does not add a finalizer into the Value. This function should only be used for autogenerated bindings.
func (*Value) GoValue ¶
func (v *Value) GoValue() interface{}
GoValue converts a Value to comparable Go type. GoValue() returns InvalidValue if the conversion was unsuccessful. The returned value must be type asserted to the actual Go type.
Unlike the type getters, although this method is not type-safe, it can get any concrete object type out, as long as there exists a marshaler for it.
func (*Value) GoValueAsType ¶ added in v0.0.5
GoValueAsType is like GoValue, except it tries to cast into the given gtype instead of the detected underlying type.
func (*Value) Init ¶ added in v0.0.5
Init initializes the Value to the given GType. It does nothing if the Value is already initialized.
func (*Value) InitGoValue ¶ added in v0.0.5
InitGoValue sets the Go value of the GValue. The GValue MUST NOT HAVE BEEN INITIALIED ALREADY!
func (*Value) Object ¶
Object is a wrapper around g_value_get_object(). The returned object is taken its own reference.
func (*Value) SetInstance ¶
SetInstance is a wrapper around g_value_set_instance().
func (*Value) SetPointer ¶
SetPointer is a wrapper around g_value_set_pointer().
func (*Value) String ¶
String is a wrapper around g_value_get_string(). String() returns a non-nil error if g_value_get_string() returned a NULL pointer to distinguish between returning a NULL pointer and returning an empty string.
func (*Value) Type ¶
Type returns the Value's actual type. is a wrapper around the G_VALUE_TYPE() macro. It returns TYPE_INVALID if v does not hold a Type, or otherwise returns the Type of v.
To get the fundamental type, use FundamentalType.
func (*Value) WalkGoValue ¶
WalkGoValue is like GoValue, except the user is walked through every single possible type of the value until it's no longer possible or until the callback returns true.
type Variant ¶
A Variant is a representation of GLib's GVariant.
func (*Variant) GoValue ¶
func (v *Variant) GoValue() interface{}
GoValue converts the variant's value to the Go value. It only supports the following types for now:
s: string b: bool d: float64 n: int16 i: int32 x: int64 y: byte q: uint16 u: uint32 t: uint64
Variants with unsupported types will cause the function to return nil.
func (*Variant) IsContainer ¶
IsContainer returns true if the variant is a container and false otherwise.
func (*Variant) IsFloating ¶
IsFloating returns true if the variant has a floating reference count. Reference counting is usually handled in the gotk layer, most applications should not call this.
func (*Variant) IsType ¶
func (v *Variant) IsType(t *VariantType) bool
IsType returns true if the variant's type matches t.
func (*Variant) Print ¶
Print wraps g_variant_print(). It returns a string understood by g_variant_parse().
func (*Variant) Ref ¶
func (v *Variant) Ref()
Ref is a wrapper around g_variant_ref. Reference counting is usually handled in the gotk layer, most applications should not need to call this.
func (*Variant) RefSink ¶
func (v *Variant) RefSink()
RefSink is a wrapper around g_variant_ref_sink. Reference counting is usually handled in the gotk layer, most applications should not need to call this.
func (*Variant) String ¶
String is a wrapper around g_variant_get_string. If the Variant type is not a string, then Print is called instead. This is done to satisfy fmt.Stringer; it behaves similarly to reflect.Value.String().
func (*Variant) TakeRef ¶
func (v *Variant) TakeRef()
TakeRef is a wrapper around g_variant_take_ref. Reference counting is usually handled in the gotk layer, most applications should not need to call this.
func (*Variant) Type ¶
func (v *Variant) Type() *VariantType
Type returns the VariantType for this variant.
func (*Variant) TypeString ¶
TypeString returns the g variant type string for this variant.
type VariantType ¶
type VariantType struct {
GVariantType *C.GVariantType
}
A VariantType is a wrapper for the GVariantType, which encodes type information for GVariants.
func NewVariantTypeNew ¶
func NewVariantTypeNew(typeString string) *VariantType
NewVariantType is a wrapper around g_variant_type_new.
func (*VariantType) Equal ¶
func (v *VariantType) Equal(to *VariantType) bool
Equal is a wrapper around g_variant_type_equal.
func (*VariantType) Free ¶
func (v *VariantType) Free()
Free is a wrapper around g_variant_type_free. Reference counting is usually handled in the gotk layer, most applications should not call this.
func (*VariantType) IsSubtypeOf ¶
func (v *VariantType) IsSubtypeOf(supertype *VariantType) bool
IsSubtypeOf is a wrapper around g_variant_type_is_subtype_of.
func (*VariantType) Native ¶
func (v *VariantType) Native() uintptr
func (*VariantType) String ¶
func (v *VariantType) String() string
String returns a copy of this VariantType's type string.
type WeakRef ¶ added in v0.0.6
type WeakRef[T Objector] struct { // contains filtered or unexported fields }
WeakRef wraps GWeakRef. It provides a container that allows the user to obtain a weak reference to a CGo GObject. The weak reference is thread-safe and will be cleared when the object is finalized.
func NewWeakRef ¶ added in v0.0.6
NewWeakRef creates a new weak reference on the Go heap to the given GObject's C pointer. The fact that the returned WeakRef is in Go-allocated memory does not actually add a reference to the object, which is the default behavior.