org.gnome.gtk.TreeSelectionFunc 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;
/**
* Functional interface declaration of the {@code TreeSelectionFunc} callback.
*
* @see TreeSelectionFunc#run
*/
@FunctionalInterface
@Generated("io.github.jwharm.JavaGI")
public interface TreeSelectionFunc extends FunctionPointer {
/**
* A function used by gtk_tree_selection_set_select_function() to filter
* whether or not a row may be selected. It is called whenever a row's
* state might change.
*
* A return value of {@code true} indicates to {@code selection} that it is okay to
* change the selection.
*/
boolean run(TreeSelection selection, TreeModel model, TreePath path,
boolean pathCurrentlySelected);
/**
* The {@code upcall} method is called from native code. The parameters
* are marshaled and {@link #run} is executed.
*/
default int upcall(MemorySegment selection, MemorySegment model, MemorySegment path,
int pathCurrentlySelected, MemorySegment data) {
Arena _arena = Arena.ofAuto();
var _result = run((TreeSelection) InstanceCache.getForType(selection, TreeSelection::new, false), (TreeModel) InstanceCache.getForType(model, TreeModel.TreeModelImpl::new, false), MemorySegment.NULL.equals(path) ? null : new TreePath(path), pathCurrentlySelected != 0);
return _result ? 1 : 0;
}
/**
* 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.JAVA_INT, ValueLayout.ADDRESS,
ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_INT,
ValueLayout.ADDRESS);
MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), TreeSelectionFunc.class, _fdesc);
return Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, arena);
}
}