org.gnome.gtk.ListBoxCreateWidgetFunc Maven / Gradle / Ivy
Show all versions of gtk Show documentation
// This file was automatically generated by Java-GI. Do not edit this file
// directly! Visit for more information.
//
// The API documentation in this file was derived from GObject-Introspection
// metadata and may include text or comments from the original C sources.
//
// Copyright (c), upstream authors as identified in the GObject-Introspection
// metadata.
//
// This generated file is distributed under the same license as the original
// GObject-Introspection data, unless otherwise specified. Users of this file
// are responsible for complying with any licenses or terms required by the
// original authors.
//
// THIS FILE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT.
//
package org.gnome.gtk;
import io.github.jwharm.javagi.base.FunctionPointer;
import io.github.jwharm.javagi.gobject.InstanceCache;
import io.github.jwharm.javagi.interop.Interop;
import java.lang.FunctionalInterface;
import java.lang.foreign.Arena;
import java.lang.foreign.FunctionDescriptor;
import java.lang.foreign.Linker;
import java.lang.foreign.MemorySegment;
import java.lang.foreign.ValueLayout;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import javax.annotation.processing.Generated;
import org.gnome.gobject.GObject;
/**
* Functional interface declaration of the {@code ListBoxCreateWidgetFunc} callback.
*
* @see ListBoxCreateWidgetFunc#run
*/
@FunctionalInterface
@Generated("io.github.jwharm.JavaGI")
public interface ListBoxCreateWidgetFunc extends FunctionPointer {
/**
* Called for list boxes that are bound to a {@code GListModel} with
* gtk_list_box_bind_model() for each item that gets added to the model.
*
* If the widget returned is not a {@code GtkListBoxRow} widget, then the widget
* will be inserted as the child of an intermediate {@code GtkListBoxRow}.
*/
Widget run(GObject item);
/**
* The {@code upcall} method is called from native code. The parameters
* are marshaled and {@link #run} is executed.
*/
default MemorySegment upcall(MemorySegment item, MemorySegment userData) {
Arena _arena = Arena.ofAuto();
var _result = run((GObject) InstanceCache.getForType(item, GObject::new, false));
if (_result == null) return MemorySegment.NULL;
if (_result instanceof GObject _gobject) _gobject.ref();
return _result.handle();
}
/**
* Creates a native function pointer to the {@link #upcall} method.
*
* @return the native function pointer
*/
default MemorySegment toCallback(Arena arena) {
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS,
ValueLayout.ADDRESS);
MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), ListBoxCreateWidgetFunc.class, _fdesc);
return Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, arena);
}
}