Exemple #1
0
func DumpCallableInfo(info *C.GICallableInfo) {
	throwsError := C.g_callable_info_can_throw_gerror(info) == C.gboolean(1)
	p("can throws error %v\n", throwsError)
	nArgs := C.g_callable_info_get_n_args(info)
	for i := C.gint(0); i < nArgs; i++ {
		argInfo := C.g_callable_info_get_arg(info, i)
		DumpArgInfo(argInfo)
	}
	returnOwnership := C.g_callable_info_get_caller_owns(info)
	p("return value ownership %s\n", TransferGetName(returnOwnership))
	returnType := C.g_callable_info_get_return_type(info)
	defer C.g_base_info_unref(asBaseInfo(returnType))
	p("return type %v\n", returnType)
	DumpTypeInfo(returnType)
	isMethod := C.g_callable_info_is_method(info) == C.gboolean(1)
	p("is method %v\n", isMethod)
	var iter C.GIAttributeIter
	var key, value *C.char
	for C.g_callable_info_iterate_return_attributes(info, &iter, &key, &value) == C.gboolean(1) {
		p("Attr %s = %s\n", C.GoString(key), C.GoString(value))
	}
	mayReturnNull := C.g_callable_info_may_return_null(info) == C.gboolean(1)
	p("may return null %v\n", mayReturnNull)
	skipReturn := C.g_callable_info_skip_return(info) == C.gboolean(1)
	p("skip return %v\n", skipReturn)
}
Exemple #2
0
/*
Modifies saturation and optionally pixelates @src, placing the result in
@dest. @src and @dest may be the same pixbuf with no ill effects.  If
@saturation is 1.0 then saturation is not changed. If it's less than 1.0,
saturation is reduced (the image turns toward grayscale); if greater than
1.0, saturation is increased (the image gets more vivid colors). If @pixelate
is %TRUE, then pixels are faded in a checkerboard pattern to create a
pixelated image. @src and @dest must have the same image format, size, and
rowstride.
*/
func (self *TraitPixbuf) SaturateAndPixelate(dest IsPixbuf, saturation float32, pixelate bool) {
	__cgo__pixelate := C.gboolean(0)
	if pixelate {
		__cgo__pixelate = C.gboolean(1)
	}
	C.gdk_pixbuf_saturate_and_pixelate(self.CPointer, dest.GetPixbufPointer(), C.gfloat(saturation), __cgo__pixelate)
	return
}
Exemple #3
0
/*
Accepts or rejects a drop.

This function is called by the drag destination in response
to a drop initiated by the drag source.
*/
func DropReply(context IsDragContext, accepted bool, time_ uint32) {
	__cgo__accepted := C.gboolean(0)
	if accepted {
		__cgo__accepted = C.gboolean(1)
	}
	C.gdk_drop_reply(context.GetDragContextPointer(), __cgo__accepted, C.guint32(time_))
	return
}
Exemple #4
0
/*
Ends the drag operation after a drop.

This function is called by the drag destination.
*/
func DropFinish(context IsDragContext, success bool, time_ uint32) {
	__cgo__success := C.gboolean(0)
	if success {
		__cgo__success = C.gboolean(1)
	}
	C.gdk_drop_finish(context.GetDragContextPointer(), __cgo__success, C.guint32(time_))
	return
}
Exemple #5
0
/*
Sets whether @animation should loop indefinitely when it reaches the end.
*/
func (self *TraitPixbufSimpleAnim) SetLoop(loop bool) {
	__cgo__loop := C.gboolean(0)
	if loop {
		__cgo__loop = C.gboolean(1)
	}
	C.gdk_pixbuf_simple_anim_set_loop(self.CPointer, __cgo__loop)
	return
}
Exemple #6
0
/*
Sets whether a trace of received events is output.
Note that GTK+ must be compiled with debugging (that is,
configured using the `--enable-debug` option)
to use this option.
*/
func SetShowEvents(show_events bool) {
	__cgo__show_events := C.gboolean(0)
	if show_events {
		__cgo__show_events = C.gboolean(1)
	}
	C.gdk_set_show_events(__cgo__show_events)
	return
}
Exemple #7
0
func GBool(val interface{}) *GValue {
	b := val.(bool)
	var cb C.gboolean
	if b {
		cb = C.gboolean(1)
	} else {
		cb = C.gboolean(0)
	}
	return CreateCGValue(G_TYPE_BOOLEAN, unsafe.Pointer(&cb))
}
Exemple #8
0
/*
Finds or creates an atom corresponding to a given string.
*/
func AtomIntern(atom_name string, only_if_exists bool) (return__ C.GdkAtom) {
	__cgo__atom_name := (*C.gchar)(unsafe.Pointer(C.CString(atom_name)))
	__cgo__only_if_exists := C.gboolean(0)
	if only_if_exists {
		__cgo__only_if_exists = C.gboolean(1)
	}
	return__ = C.gdk_atom_intern(__cgo__atom_name, __cgo__only_if_exists)
	C.free(unsafe.Pointer(__cgo__atom_name))
	return
}
Exemple #9
0
/*
Flips a pixbuf horizontally or vertically and returns the
result in a new pixbuf.
*/
func (self *TraitPixbuf) Flip(horizontal bool) (return__ *Pixbuf) {
	__cgo__horizontal := C.gboolean(0)
	if horizontal {
		__cgo__horizontal = C.gboolean(1)
	}
	var __cgo__return__ *C.GdkPixbuf
	__cgo__return__ = C.gdk_pixbuf_flip(self.CPointer, __cgo__horizontal)
	if __cgo__return__ != nil {
		return__ = NewPixbufFromCPointer(unsafe.Pointer(reflect.ValueOf(__cgo__return__).Pointer()))
	}
	return
}
Exemple #10
0
/*
Takes an existing pixbuf and adds an alpha channel to it.
If the existing pixbuf already had an alpha channel, the channel
values are copied from the original; otherwise, the alpha channel
is initialized to 255 (full opacity).

If @substitute_color is %TRUE, then the color specified by (@r, @g, @b) will be
assigned zero opacity. That is, if you pass (255, 255, 255) for the
substitute color, all white pixels will become fully transparent.
*/
func (self *TraitPixbuf) AddAlpha(substitute_color bool, r uint8, g uint8, b uint8) (return__ *Pixbuf) {
	__cgo__substitute_color := C.gboolean(0)
	if substitute_color {
		__cgo__substitute_color = C.gboolean(1)
	}
	var __cgo__return__ *C.GdkPixbuf
	__cgo__return__ = C.gdk_pixbuf_add_alpha(self.CPointer, __cgo__substitute_color, C.guchar(r), C.guchar(g), C.guchar(b))
	if __cgo__return__ != nil {
		return__ = NewPixbufFromCPointer(unsafe.Pointer(reflect.ValueOf(__cgo__return__).Pointer()))
	}
	return
}
/*
Creates a new #GdkPixbuf out of in-memory readonly image data.
Currently only RGB images with 8 bits per sample are supported.
This is the #GBytes variant of gdk_pixbuf_new_from_data().
*/
func PixbufNewFromBytes(data *C.GBytes, colorspace C.GdkColorspace, has_alpha bool, bits_per_sample int, width int, height int, rowstride int) (return__ *Pixbuf) {
	__cgo__has_alpha := C.gboolean(0)
	if has_alpha {
		__cgo__has_alpha = C.gboolean(1)
	}
	var __cgo__return__ interface{}
	__cgo__return__ = C.gdk_pixbuf_new_from_bytes(data, colorspace, __cgo__has_alpha, C.int(bits_per_sample), C.int(width), C.int(height), C.int(rowstride))
	if __cgo__return__ != nil {
		return__ = NewPixbufFromCPointer(unsafe.Pointer(reflect.ValueOf(__cgo__return__).Pointer()))
	}
	return
}
/*
Creates a new #GdkPixbuf out of in-memory image data.  Currently only RGB
images with 8 bits per sample are supported.

Since you are providing a pre-allocated pixel buffer, you must also
specify a way to free that data.  This is done with a function of
type #GdkPixbufDestroyNotify.  When a pixbuf created with is
finalized, your destroy notification function will be called, and
it is its responsibility to free the pixel array.

See also gdk_pixbuf_new_from_bytes().
*/
func PixbufNewFromData(data []byte, colorspace C.GdkColorspace, has_alpha bool, bits_per_sample int, width int, height int, rowstride int, destroy_fn C.GdkPixbufDestroyNotify, destroy_fn_data unsafe.Pointer) (return__ *Pixbuf) {
	__header__data := (*reflect.SliceHeader)(unsafe.Pointer(&data))
	__cgo__has_alpha := C.gboolean(0)
	if has_alpha {
		__cgo__has_alpha = C.gboolean(1)
	}
	var __cgo__return__ interface{}
	__cgo__return__ = C.gdk_pixbuf_new_from_data((*C.guchar)(unsafe.Pointer(__header__data.Data)), colorspace, __cgo__has_alpha, C.int(bits_per_sample), C.int(width), C.int(height), C.int(rowstride), destroy_fn, (C.gpointer)(destroy_fn_data))
	if __cgo__return__ != nil {
		return__ = NewPixbufFromCPointer(unsafe.Pointer(reflect.ValueOf(__cgo__return__).Pointer()))
	}
	return
}
Exemple #13
0
/*
Sets the #GdkWindow @owner as the current owner of the selection @selection.
*/
func SelectionOwnerSetForDisplay(display IsDisplay, owner IsWindow, selection C.GdkAtom, time_ uint32, send_event bool) (return__ bool) {
	var __cgo__owner *C.GdkWindow
	if owner != nil {
		__cgo__owner = owner.GetWindowPointer()
	}
	__cgo__send_event := C.gboolean(0)
	if send_event {
		__cgo__send_event = C.gboolean(1)
	}
	var __cgo__return__ C.gboolean
	__cgo__return__ = C.gdk_selection_owner_set_for_display(display.GetDisplayPointer(), __cgo__owner, selection, C.guint32(time_), __cgo__send_event)
	return__ = __cgo__return__ == C.gboolean(1)
	return
}
/*
Creates a new pixbuf by loading an image from an input stream.

The file format is detected automatically. If %NULL is returned, then
@error will be set. The @cancellable can be used to abort the operation
from another thread. If the operation was cancelled, the error
%G_IO_ERROR_CANCELLED will be returned. Other possible errors are in
the #GDK_PIXBUF_ERROR and %G_IO_ERROR domains.

The image will be scaled to fit in the requested size, optionally
preserving the image's aspect ratio.

When preserving the aspect ratio, a @width of -1 will cause the image to be
scaled to the exact given height, and a @height of -1 will cause the image
to be scaled to the exact given width. If both @width and @height are
given, this function will behave as if the smaller of the two values
is passed as -1.

When not preserving aspect ratio, a @width or @height of -1 means to not
scale the image at all in that dimension.

The stream is not closed.
*/
func PixbufNewFromStreamAtScale(stream *C.GInputStream, width int, height int, preserve_aspect_ratio bool, cancellable *C.GCancellable) (return__ *Pixbuf, __err__ error) {
	__cgo__preserve_aspect_ratio := C.gboolean(0)
	if preserve_aspect_ratio {
		__cgo__preserve_aspect_ratio = C.gboolean(1)
	}
	var __cgo_error__ *C.GError
	var __cgo__return__ interface{}
	__cgo__return__ = C.gdk_pixbuf_new_from_stream_at_scale(stream, C.gint(width), C.gint(height), __cgo__preserve_aspect_ratio, cancellable, &__cgo_error__)
	if __cgo__return__ != nil {
		return__ = NewPixbufFromCPointer(unsafe.Pointer(reflect.ValueOf(__cgo__return__).Pointer()))
	}
	if __cgo_error__ != nil {
		__err__ = errors.New(C.GoString((*C.char)(unsafe.Pointer(__cgo_error__.message))))
	}
	return
}
Exemple #15
0
func DumpUnionInfo(info *C.GIUnionInfo) {
	nFields := C.g_union_info_get_n_fields(info)
	p("%d fields\n", nFields)
	for i := C.gint(0); i < nFields; i++ {
		field := C.g_union_info_get_field(info, i)
		DumpFieldInfo(field)
	}
	nMethods := C.g_union_info_get_n_methods(info)
	p("%d methods\n", nMethods)
	for i := C.gint(0); i < nMethods; i++ {
		method := C.g_union_info_get_method(info, i)
		DumpFunctionInfo(method)
	}
	isDiscriminated := C.g_union_info_is_discriminated(info) == C.gboolean(1)
	p("is discriminated %v\n", isDiscriminated)
	if isDiscriminated {
		offset := C.g_union_info_get_discriminator_offset(info)
		p("discriminated offset %d\n", offset)
		discriminatedType := C.g_union_info_get_discriminator_type(info)
		p("discriminated type %d\n", discriminatedType)
		DumpTypeInfo(discriminatedType)
		for i := C.gint(0); i < nFields; i++ {
			discriminator := C.g_union_info_get_discriminator(info, i)
			DumpConstantInfo(discriminator)
		}
	}
	size := C.g_union_info_get_size(info)
	p("size %d bytes\n", size)
	align := C.g_union_info_get_alignment(info)
	p("alignment %d bytes\n", align)
}
Exemple #16
0
func (v *Value) Get() interface{} {
	t := Type(v.g().g_type)
	switch t {
	case TYPE_INVALID:
		return nil

	case TYPE_STRING:
		return C.GoString((*C.char)(C.g_value_get_string(v.g())))

	case TYPE_GO_INT:
		return int(C.g_value_get_long(v.g()))

	case TYPE_GO_UINT:
		return uint(C.g_value_get_ulong(v.g()))

	case TYPE_CHAR:
		return int8(C.g_value_get_schar(v.g()))

	case TYPE_UCHAR:
		return uint8(C.g_value_get_uchar(v.g()))

	case TYPE_GO_INT32:
		return int32(C.g_value_get_int(v.g()))

	case TYPE_GO_UINT32:
		return uint32(C.g_value_get_uint(v.g()))

	case TYPE_INT64:
		return int64(C.g_value_get_int64(v.g()))

	case TYPE_UINT64:
		return uint64(C.g_value_get_uint64(v.g()))

	case TYPE_BOOLEAN:
		return (C.g_value_get_boolean(v.g()) != C.gboolean(0))

	case TYPE_FLOAT:
		return float32(C.g_value_get_float(v.g()))

	case TYPE_DOUBLE:
		return float64(C.g_value_get_double(v.g()))

	case TYPE_POINTER:
		return Pointer(C.g_value_get_pointer(v.g()))

	case TYPE_GTYPE:
		return Type(C.g_value_get_gtype(v.g()))
	}
	if t.IsA(TYPE_OBJECT) {
		o := new(Object)
		o.SetPtr(Pointer(C.g_value_get_object(v.g())))
		return o
	}
	if C.g_value_fits_pointer(v.g()) != 0 {
		return Pointer(C.g_value_peek_pointer(v.g()))
	}
	// Value of unknown type is returned as is
	return v
}
Exemple #17
0
/*
If both events contain X/Y information, this function will return %TRUE
and return in @angle the relative angle from @event1 to @event2. The rotation
direction for positive angles is from the positive X axis towards the positive
Y axis.
*/
func EventsGetAngle(event1 *C.GdkEvent, event2 *C.GdkEvent) (angle float64, return__ bool) {
	var __cgo__angle C.gdouble
	var __cgo__return__ C.gboolean
	__cgo__return__ = C.gdk_events_get_angle(event1, event2, &__cgo__angle)
	angle = float64(__cgo__angle)
	return__ = __cgo__return__ == C.gboolean(1)
	return
}
Exemple #18
0
/*
Obtains a desktop-wide setting, such as the double-click time,
for the default screen. See gdk_screen_get_setting().
*/
func SettingGet(name string, value *C.GValue) (return__ bool) {
	__cgo__name := (*C.gchar)(unsafe.Pointer(C.CString(name)))
	var __cgo__return__ C.gboolean
	__cgo__return__ = C.gdk_setting_get(__cgo__name, value)
	C.free(unsafe.Pointer(__cgo__name))
	return__ = __cgo__return__ == C.gboolean(1)
	return
}
Exemple #19
0
/*
If both events have X/Y information, the distance between both coordinates
(as in a straight line going from @event1 to @event2) will be returned.
*/
func EventsGetDistance(event1 *C.GdkEvent, event2 *C.GdkEvent) (distance float64, return__ bool) {
	var __cgo__distance C.gdouble
	var __cgo__return__ C.gboolean
	__cgo__return__ = C.gdk_events_get_distance(event1, event2, &__cgo__distance)
	distance = float64(__cgo__distance)
	return__ = __cgo__return__ == C.gboolean(1)
	return
}
/*
Create a #GdkPixbuf from a flat representation that is suitable for
storing as inline data in a program. This is useful if you want to
ship a program with images, but don't want to depend on any
external files.

gdk-pixbuf ships with a program called [gdk-pixbuf-csource][gdk-pixbuf-csource],
which allows for conversion of #GdkPixbufs into such a inline representation.
In almost all cases, you should pass the `--raw` option to
`gdk-pixbuf-csource`. A sample invocation would be:

|[
 gdk-pixbuf-csource --raw --name=myimage_inline myimage.png
]|

For the typical case where the inline pixbuf is read-only static data,
you don't need to copy the pixel data unless you intend to write to
it, so you can pass %FALSE for @copy_pixels.  (If you pass `--rle` to
`gdk-pixbuf-csource`, a copy will be made even if @copy_pixels is %FALSE,
so using this option is generally a bad idea.)

If you create a pixbuf from const inline data compiled into your
program, it's probably safe to ignore errors and disable length checks,
since things will always succeed:
|[
pixbuf = gdk_pixbuf_new_from_inline (-1, myimage_inline, FALSE, NULL);
]|

For non-const inline data, you could get out of memory. For untrusted
inline data located at runtime, you could have corrupt inline data in
addition.
*/
func PixbufNewFromInline(data_length int, data []byte, copy_pixels bool) (return__ *Pixbuf, __err__ error) {
	__header__data := (*reflect.SliceHeader)(unsafe.Pointer(&data))
	__cgo__copy_pixels := C.gboolean(0)
	if copy_pixels {
		__cgo__copy_pixels = C.gboolean(1)
	}
	var __cgo_error__ *C.GError
	var __cgo__return__ interface{}
	__cgo__return__ = C.gdk_pixbuf_new_from_inline(C.gint(data_length), (*C.guint8)(unsafe.Pointer(__header__data.Data)), __cgo__copy_pixels, &__cgo_error__)
	if __cgo__return__ != nil {
		return__ = NewPixbufFromCPointer(unsafe.Pointer(reflect.ValueOf(__cgo__return__).Pointer()))
	}
	if __cgo_error__ != nil {
		__err__ = errors.New(C.GoString((*C.char)(unsafe.Pointer(__cgo_error__.message))))
	}
	return
}
Exemple #21
0
/*
Compares the user data for the key @key on @object with
@oldval, and if they are the same, replaces @oldval with
@newval.

This is like a typical atomic compare-and-exchange
operation, for user data on an object.

If the previous value was replaced then ownership of the
old value (@oldval) is passed to the caller, including
the registered destroy notify for it (passed out in @old_destroy).
Its up to the caller to free this as he wishes, which may
or may not include using @old_destroy as sometimes replacement
should not destroy the object in the normal way.
*/
func (self *TraitObject) ReplaceData(key string, oldval unsafe.Pointer, newval unsafe.Pointer, destroy C.GDestroyNotify, old_destroy *C.GDestroyNotify) (return__ bool) {
	__cgo__key := (*C.gchar)(unsafe.Pointer(C.CString(key)))
	var __cgo__return__ C.gboolean
	__cgo__return__ = C.g_object_replace_data(self.CPointer, __cgo__key, (C.gpointer)(oldval), (C.gpointer)(newval), destroy, old_destroy)
	C.free(unsafe.Pointer(__cgo__key))
	return__ = __cgo__return__ == C.gboolean(1)
	return
}
/*
Creates a new pixbuf by loading an image from an resource.

The file format is detected automatically. If %NULL is returned, then
@error will be set.

The image will be scaled to fit in the requested size, optionally
preserving the image's aspect ratio. When preserving the aspect ratio,
a @width of -1 will cause the image to be scaled to the exact given
height, and a @height of -1 will cause the image to be scaled to the
exact given width. When not preserving aspect ratio, a @width or
@height of -1 means to not scale the image at all in that dimension.

The stream is not closed.
*/
func PixbufNewFromResourceAtScale(resource_path string, width int, height int, preserve_aspect_ratio bool) (return__ *Pixbuf, __err__ error) {
	__cgo__resource_path := C.CString(resource_path)
	__cgo__preserve_aspect_ratio := C.gboolean(0)
	if preserve_aspect_ratio {
		__cgo__preserve_aspect_ratio = C.gboolean(1)
	}
	var __cgo_error__ *C.GError
	var __cgo__return__ interface{}
	__cgo__return__ = C.gdk_pixbuf_new_from_resource_at_scale(__cgo__resource_path, C.int(width), C.int(height), __cgo__preserve_aspect_ratio, &__cgo_error__)
	C.free(unsafe.Pointer(__cgo__resource_path))
	if __cgo__return__ != nil {
		return__ = NewPixbufFromCPointer(unsafe.Pointer(reflect.ValueOf(__cgo__return__).Pointer()))
	}
	if __cgo_error__ != nil {
		__err__ = errors.New(C.GoString((*C.char)(unsafe.Pointer(__cgo_error__.message))))
	}
	return
}
Exemple #23
0
/*
This will cause a pixbuf loader to parse a buffer inside a #GBytes
for an image.  It will return %TRUE if the data was loaded successfully,
and %FALSE if an error occurred.  In the latter case, the loader
will be closed, and will not accept further writes. If %FALSE is
returned, @error will be set to an error from the #GDK_PIXBUF_ERROR
or #G_FILE_ERROR domains.

See also: gdk_pixbuf_loader_write()
*/
func (self *TraitPixbufLoader) WriteBytes(buffer *C.GBytes) (return__ bool, __err__ error) {
	var __cgo_error__ *C.GError
	var __cgo__return__ C.gboolean
	__cgo__return__ = C.gdk_pixbuf_loader_write_bytes(self.CPointer, buffer, &__cgo_error__)
	return__ = __cgo__return__ == C.gboolean(1)
	if __cgo_error__ != nil {
		__err__ = errors.New(C.GoString((*C.char)(unsafe.Pointer(__cgo_error__.message))))
	}
	return
}
Exemple #24
0
/*
If both events contain X/Y information, the center of both coordinates
will be returned in @x and @y.
*/
func EventsGetCenter(event1 *C.GdkEvent, event2 *C.GdkEvent) (x float64, y float64, return__ bool) {
	var __cgo__x C.gdouble
	var __cgo__y C.gdouble
	var __cgo__return__ C.gboolean
	__cgo__return__ = C.gdk_events_get_center(event1, event2, &__cgo__x, &__cgo__y)
	x = float64(__cgo__x)
	y = float64(__cgo__y)
	return__ = __cgo__return__ == C.gboolean(1)
	return
}
Exemple #25
0
func DumpObjectInfo(info *C.GIObjectInfo) {
	isAbstract := C.g_object_info_get_abstract(info) == C.gboolean(1)
	p("is abstract %v\n", isAbstract)
	parent := C.g_object_info_get_parent(info)
	if parent != nil {
		parentName := fromGStr(C.g_base_info_get_name(asBaseInfo(parent)))
		p("parent %s\n", parentName)
	}
	typeName := fromGStr(C.g_object_info_get_type_name(info))
	p("type name %s\n", typeName)
	typeInit := fromGStr(C.g_object_info_get_type_init(info))
	p("type init %s\n", typeInit)
	nConsts := C.g_object_info_get_n_constants(info)
	p("%d consts\n", nConsts)
	for i := C.gint(0); i < nConsts; i++ {
		constInfo := C.g_object_info_get_constant(info, i)
		DumpConstantInfo(constInfo)
	}
	nFields := C.g_object_info_get_n_fields(info)
	p("%d fields\n", nFields)
	for i := C.gint(0); i < nFields; i++ {
		field := C.g_object_info_get_field(info, i)
		DumpFieldInfo(field)
	}
	nInterfaces := C.g_object_info_get_n_interfaces(info)
	p("%d interfaces\n", nInterfaces)
	for i := C.gint(0); i < nInterfaces; i++ {
		interf := C.g_object_info_get_interface(info, i)
		DumpInterfaceInfo(interf)
	}
	nMethods := C.g_object_info_get_n_methods(info)
	p("%d methods\n", nMethods)
	for i := C.gint(0); i < nMethods; i++ {
		f := C.g_object_info_get_method(info, i)
		DumpFunctionInfo(f)
	}
	nProperties := C.g_object_info_get_n_properties(info)
	p("%d properties\n", nProperties)
	for i := C.gint(0); i < nProperties; i++ {
		property := C.g_object_info_get_property(info, i)
		DumpPropertyInfo(property)
	}
	nSignals := C.g_object_info_get_n_signals(info)
	p("%d signals\n", nSignals)
	for i := C.gint(0); i < nSignals; i++ {
		signal := C.g_object_info_get_signal(info, i)
		DumpSignalInfo(signal)
	}
	nVFuncs := C.g_object_info_get_n_vfuncs(info)
	p("%d vfuncs\n", nVFuncs)
	for i := C.gint(0); i < nVFuncs; i++ {
		vfunc := C.g_object_info_get_vfunc(info, i)
		DumpVFuncInfo(vfunc)
	}
}
Exemple #26
0
/*
This will cause a pixbuf loader to parse the next @count bytes of
an image.  It will return %TRUE if the data was loaded successfully,
and %FALSE if an error occurred.  In the latter case, the loader
will be closed, and will not accept further writes. If %FALSE is
returned, @error will be set to an error from the #GDK_PIXBUF_ERROR
or #G_FILE_ERROR domains.
*/
func (self *TraitPixbufLoader) Write(buf []byte, count int64) (return__ bool, __err__ error) {
	__header__buf := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
	var __cgo_error__ *C.GError
	var __cgo__return__ C.gboolean
	__cgo__return__ = C.gdk_pixbuf_loader_write(self.CPointer, (*C.guchar)(unsafe.Pointer(__header__buf.Data)), C.gsize(count), &__cgo_error__)
	return__ = __cgo__return__ == C.gboolean(1)
	if __cgo_error__ != nil {
		__err__ = errors.New(C.GoString((*C.char)(unsafe.Pointer(__cgo_error__.message))))
	}
	return
}
Exemple #27
0
func Connect(obj unsafe.Pointer, signal string, cb interface{}) uint64 {
	cbp := &cb
	refHolderLock.Lock()
	refHolder = append(refHolder, cbp) //FIXME deref
	refHolderLock.Unlock()
	closure := C.new_closure(unsafe.Pointer(cbp))
	cSignal := (*C.gchar)(unsafe.Pointer(C.CString(signal)))
	defer C.free(unsafe.Pointer(cSignal))
	id := C.g_signal_connect_closure(C.gpointer(obj), cSignal, closure, C.gboolean(0))
	return uint64(id)
}
Exemple #28
0
func main() {
	var loop *C.GMainLoop
	var s0 byte
	mdir := ""

	flag.StringVar(&mdir, "mdir", "", "mp3文件目录")
	flag.BoolVar(&g_isOutOfOrder, "rand", false, "是否乱序播放")
	flag.Parse()

	if mdir == "" {
		flag.PrintDefaults()
		return
	}
	g_list = list.New()
	g_wg = new(sync.WaitGroup)
	C.gst_init((*C.int)(unsafe.Pointer(nil)),
		(***C.char)(unsafe.Pointer(nil)))
	loop = C.g_main_loop_new((*C.GMainContext)(unsafe.Pointer(nil)),
		C.gboolean(0)) // 创建主循环,在执行 g_main_loop_run后正式开始循环

	if err := filepath.Walk(mdir, walkFunc); err != nil {
		fmt.Printf("Error: %v\n", err)
		return
	}
	g_wg.Add(1)
	s := make(chan byte)
	defer close(s)
	go mp3_play_process(s, loop)
LOOP0:
	for {
		fmt.Fscanf(os.Stdin, "%c\n", &s0)
		switch s0 {
		case 's':
			s <- s0
		case 'r':
			s <- s0
		case 'n':
			s <- s0
		case 'p':
			s <- s0
		case 'q':
			s <- s0
			break LOOP0
		case 'h':
			fmt.Print("'s' -> 暂停\n" +
				"'r' -> 继续\n" +
				"'n' -> 下一首\n" +
				"'p' -> 上一首\n" +
				"'q' -> 退出\n")
		}
		s0 = 0
	}
	g_wg.Wait()
}
Exemple #29
0
/*
Retrieves a portion of the contents of a property. If the
property does not exist, then the function returns %FALSE,
and %GDK_NONE will be stored in @actual_property_type.

The XGetWindowProperty() function that gdk_property_get()
uses has a very confusing and complicated set of semantics.
Unfortunately, gdk_property_get() makes the situation
worse instead of better (the semantics should be considered
undefined), and also prints warnings to stderr in cases where it
should return a useful error to the program. You are advised to use
XGetWindowProperty() directly until a replacement function for
gdk_property_get() is provided.
*/
func PropertyGet(window IsWindow, property C.GdkAtom, type_ C.GdkAtom, offset uint64, length uint64, pdelete int) (actual_property_type C.GdkAtom, actual_format int, actual_length int, data string, return__ bool) {
	var __cgo__actual_format C.gint
	var __cgo__actual_length C.gint
	var __cgo__data *C.guchar
	var __cgo__return__ C.gboolean
	__cgo__return__ = C.gdk_property_get(window.GetWindowPointer(), property, type_, C.gulong(offset), C.gulong(length), C.gint(pdelete), &actual_property_type, &__cgo__actual_format, &__cgo__actual_length, &__cgo__data)
	actual_format = int(__cgo__actual_format)
	actual_length = int(__cgo__actual_length)
	data = C.GoString((*C.char)(unsafe.Pointer(__cgo__data)))
	return__ = __cgo__return__ == C.gboolean(1)
	return
}
Exemple #30
0
func DumpStructInfo(info *C.GIStructInfo) {
	align := C.g_struct_info_get_alignment(info)
	p("alignment %d bytes\n", align)
	size := C.g_struct_info_get_size(info)
	p("size %d bytes\n", size)
	isGtypeStruct := C.g_struct_info_is_gtype_struct(info) == C.gboolean(1)
	p("is gtype struct %v\n", isGtypeStruct)
	isForeign := C.g_struct_info_is_foreign(info) == C.gboolean(1)
	p("is foreign %v\n", isForeign)
	nFields := C.g_struct_info_get_n_fields(info)
	p("%d fields\n", nFields)
	for i := C.gint(0); i < nFields; i++ {
		field := C.g_struct_info_get_field(info, i)
		DumpFieldInfo(field)
	}
	nMethods := C.g_struct_info_get_n_methods(info)
	p("%d methods\n", nMethods)
	for i := C.gint(0); i < nMethods; i++ {
		f := C.g_struct_info_get_method(info, i)
		DumpFunctionInfo(f)
	}
}