作者:reuse
项目:gg
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)
}
作者:reuse
项目:ggi
/*
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
}
作者:reuse
项目:ggi
/*
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
}
作者:reuse
项目:ggi
/*
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
}
作者:reuse
项目:ggi
/*
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
}
作者:reuse
项目:ggi
/*
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
}
作者:naps
项目:go-gtk
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))
}
作者:reuse
项目:ggi
/*
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
}
作者:reuse
项目:ggi
/*
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
}
作者:reuse
项目:ggi
/*
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
}
作者:reuse
项目:ggi
/*
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
}
作者:reuse
项目:ggi
/*
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
}
作者:reuse
项目:ggi
/*
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
}
作者:reuse
项目:ggi
/*
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
}
作者:reuse
项目:gg
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)
}
作者:ziute
项目:gli
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
}
作者:reuse
项目:ggi
/*
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
}
作者:reuse
项目:ggi
/*
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
}
作者:reuse
项目:ggi
/*
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
}
作者:reuse
项目:ggi
/*
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
}