Documentation ¶
Overview ¶
Package glib provides Go bindings for GLib 2. Supports version 2.36 and later.
Index ¶
- Constants
- func ClosureNew(f interface{}, marshalData ...interface{}) (*C.GClosure, error)
- func GetUserSpecialDir(directory UserDirectory) (string, error)
- func RegisterGValueMarshalers(tm []TypeMarshaler)
- func ToGObject(p unsafe.Pointer) *C.GObject
- type GValueMarshaler
- type IObject
- type InitiallyUnowned
- type List
- type Object
- func (v *Object) Connect(detailedSignal string, f interface{}, userData ...interface{}) (SignalHandle, error)
- func (v *Object) Emit(s string, args ...interface{}) (interface{}, error)
- func (v *Object) ForceFloating()
- 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) IsFloating() bool
- func (v *Object) Native() uintptr
- func (v *Object) Ref()
- func (v *Object) RefSink()
- func (v *Object) Set(name string, value interface{}) error
- func (v *Object) StopEmission(s string)
- func (v *Object) TypeFromInstance() Type
- func (v *Object) Unref()
- type SList
- type SignalHandle
- type SourceHandle
- type Type
- type TypeMarshaler
- type UserDirectory
- type Value
- func (v *Value) GetString() (string, error)
- func (v *Value) GoValue() (interface{}, error)
- func (v *Value) Native() uintptr
- 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) 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) Type() (actual Type, fundamental Type, err error)
Constants ¶
const USER_N_DIRECTORIES int = C.G_USER_N_DIRECTORIES
Variables ¶
This section is empty.
Functions ¶
func ClosureNew ¶
ClosureNew creates a new GClosure and adds its callback function to the internally-maintained map. It's exported for visibility to other gotk3 packages and shouldn't be used in application code.
func GetUserSpecialDir ¶
func GetUserSpecialDir(directory UserDirectory) (string, error)
GetUserSpecialDir is a wrapper around g_get_user_special_dir(). A non-nil error is returned in the case that g_get_user_special_dir() returns NULL to differentiate between NULL and an empty string.
func RegisterGValueMarshalers ¶
func RegisterGValueMarshalers(tm []TypeMarshaler)
RegisterGValueMarshalers adds marshalers for several types to the internal marshalers map. Once registered, calling GoValue on any Value witha registered type will return the data returned by the marshaler.
Types ¶
type GValueMarshaler ¶
GValueMarshaler is a marshal function to convert a GValue into an appropiate Go type. The uintptr parameter is a *C.GValue.
type IObject ¶
type IObject interface {
// contains filtered or unexported methods
}
IObject is an interface type implemented by Object and all types which embed an Object. It is meant to be used as a type for function arguments which require GObjects or any subclasses thereof.
type InitiallyUnowned ¶
type InitiallyUnowned struct { // This must be a pointer so copies of the ref-sinked object // do not outlive the original object, causing an unref // finalizer to prematurely run. *Object }
InitiallyUnowned is a representation of GLib's GInitiallyUnowned.
func (*InitiallyUnowned) Native ¶
func (v *InitiallyUnowned) Native() uintptr
Native returns a pointer to the underlying GObject. This is implemented here rather than calling Native on the embedded Object to prevent a nil pointer dereference.
type List ¶
List is a representation of Glib's GList.
type Object ¶
Object is a representation of GLib's GObject.
func (*Object) Connect ¶
func (v *Object) Connect(detailedSignal string, f interface{}, userData ...interface{}) (SignalHandle, error)
Connect is a wrapper around g_signal_connect_closure(). f must be a function with a signaure matching the callback signature for detailedSignal. userData must either 0 or 1 elements which can be optionally passed to f. If f takes less arguments than it is passed from the GLib runtime, the extra arguments are ignored.
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) Emit ¶
Emit is a wrapper around g_signal_emitv() and 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 as the Go equivalent type to the return value for 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) ForceFloating ¶
func (v *Object) ForceFloating()
ForceFloating is a wrapper around g_object_force_floating().
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) IsFloating ¶
IsFloating is a wrapper around g_object_is_floating().
func (*Object) RefSink ¶
func (v *Object) RefSink()
RefSink is a wrapper around g_object_ref_sink().
func (*Object) Set ¶
Set is a wrapper around g_object_set(). However, unlike g_object_set(), this function only sets one name value pair. Make multiple calls to this function to set multiple properties.
func (*Object) StopEmission ¶
StopEmission is a wrapper around g_signal_stop_emission_by_name().
func (*Object) TypeFromInstance ¶
TypeFromInstance is a wrapper around g_type_from_instance().
type SignalHandle ¶
type SignalHandle uint
type SourceHandle ¶
type SourceHandle uint
func IdleAdd ¶
func IdleAdd(f interface{}, args ...interface{}) (SourceHandle, error)
IdleAdd adds an idle source to the default main event loop context. After running once, the source func will be removed from the main event loop, unless f returns a single bool true.
This function will cause a panic when f eventually runs if the types of args do not match those of f.
func TimeoutAdd ¶
func TimeoutAdd(timeout uint, f interface{}, args ...interface{}) (SourceHandle, error)
TimeoutAdd adds an timeout source to the default main event loop context. After running once, the source func will be removed from the main event loop, unless f returns a single bool true.
This function will cause a panic when f eventually runs if the types of args do not match those of f. timeout is in milliseconds
type Type ¶
type Type uint
Type is a representation of GLib's GType.
const ( TYPE_INVALID Type = C.G_TYPE_INVALID TYPE_NONE Type = C.G_TYPE_NONE TYPE_INTERFACE Type = C.G_TYPE_INTERFACE TYPE_CHAR Type = C.G_TYPE_CHAR TYPE_UCHAR Type = C.G_TYPE_UCHAR TYPE_BOOLEAN Type = C.G_TYPE_BOOLEAN TYPE_INT Type = C.G_TYPE_INT TYPE_UINT Type = C.G_TYPE_UINT TYPE_LONG Type = C.G_TYPE_LONG TYPE_ULONG Type = C.G_TYPE_ULONG TYPE_INT64 Type = C.G_TYPE_INT64 TYPE_UINT64 Type = C.G_TYPE_UINT64 TYPE_ENUM Type = C.G_TYPE_ENUM TYPE_FLAGS Type = C.G_TYPE_FLAGS TYPE_FLOAT Type = C.G_TYPE_FLOAT TYPE_DOUBLE Type = C.G_TYPE_DOUBLE TYPE_STRING Type = C.G_TYPE_STRING TYPE_POINTER Type = C.G_TYPE_POINTER TYPE_BOXED Type = C.G_TYPE_BOXED TYPE_PARAM Type = C.G_TYPE_PARAM TYPE_OBJECT Type = C.G_TYPE_OBJECT TYPE_VARIANT Type = C.G_TYPE_VARIANT )
type TypeMarshaler ¶
type TypeMarshaler struct { T Type F GValueMarshaler }
TypeMarshaler represents an actual type and it's associated marshaler.
type UserDirectory ¶
type UserDirectory int
UserDirectory is a representation of GLib's GUserDirectory.
const ( USER_DIRECTORY_DESKTOP UserDirectory = C.G_USER_DIRECTORY_DESKTOP USER_DIRECTORY_DOCUMENTS UserDirectory = C.G_USER_DIRECTORY_DOCUMENTS USER_DIRECTORY_DOWNLOAD UserDirectory = C.G_USER_DIRECTORY_DOWNLOAD USER_DIRECTORY_MUSIC UserDirectory = C.G_USER_DIRECTORY_MUSIC USER_DIRECTORY_PICTURES UserDirectory = C.G_USER_DIRECTORY_PICTURES USER_DIRECTORY_PUBLIC_SHARE UserDirectory = C.G_USER_DIRECTORY_PUBLIC_SHARE USER_DIRECTORY_TEMPLATES UserDirectory = C.G_USER_DIRECTORY_TEMPLATES USER_DIRECTORY_VIDEOS UserDirectory = C.G_USER_DIRECTORY_VIDEOS )
type Value ¶
Value is a representation of GLib's GValue.
Don't allocate Values on the stack or heap manually as they may not be properly unset when going out of scope. Instead, use ValueAlloc(), which will set the runtime finalizer to unset the Value after it has left scope.
func GValue ¶
GValue converts a Go type to a comparable GValue. GValue() returns a non-nil error if the conversion was unsuccessful.
func ValueAlloc ¶
ValueAlloc allocates a Value and sets a runtime finalizer to call g_value_unset() on the underlying GValue after leaving scope. ValueAlloc() returns a non-nil error if the allocation failed.
func ValueInit ¶
ValueInit 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 (*Value) GetString ¶
GetString is a wrapper around g_value_get_string(). GetString() 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) GoValue ¶
GoValue converts a Value to comparable Go type. GoValue() returns a non-nil error if the conversion was unsuccessful. The returned interface{} must be type asserted as the actual Go representation of the Value.
This function is a wrapper around the many g_value_get_*() functions, depending on the type of the Value.
func (*Value) SetInstance ¶
SetInstance is a wrapper around g_value_set_instance().
func (*Value) SetPointer ¶
SetPointer is a wrapper around g_value_set_pointer().