Support request: Help gtk-kt with GIR #14
Replies: 3 comments
-
Hi, What is the desired output of that "GIR generator"? Will it be Kotlin code? And if so how will it link to the C-Library? Will it call an autogenerated "cinterop" API? |
Beta Was this translation helpful? Give feedback.
-
It will can an auto generated cinterop API. The Kotlin multi platform stack generates these plugins via definition files that point to relevant headers and other C related information. The main goal on my side is to get Kotlin/Native generation up and running. But I also want to eventually create Java bindings as well under the tree. |
Beta Was this translation helpful? Give feedback.
-
Hi @bailuk thank you for coming back to us! This is an example of a generated kotlin native class: package org.gtk
import glib.gint
import gtk.GtkBox
import gtk.gtk_box_append
import gtk.gtk_box_get_baseline_position
import gtk.gtk_box_get_homogeneous
import gtk.gtk_box_get_spacing
import gtk.gtk_box_insert_child_after
import gtk.gtk_box_prepend
import gtk.gtk_box_remove
import gtk.gtk_box_reorder_child_after
import gtk.gtk_box_set_baseline_position
import gtk.gtk_box_set_homogeneous
import gtk.gtk_box_set_spacing
import kotlin.Boolean
import kotlin.Int
import kotlin.Unit
import kotlinx.cinterop.CPointer
import kotlinx.cinterop.reinterpret
import org.gtk.Accessible
import org.gtk.BaselinePosition
import org.gtk.Buildable
import org.gtk.ConstraintTarget
import org.gtk.Orientable
import org.gtk.Widget
import org.gtk.glib.bool
import org.gtk.glib.gtk
/**
* The `GtkBox` widget arranges child widgets into a single row or column.
*
* ![An example GtkBox](box.png)
*
* Whether it is a row or column depends on the value of its
* [[email protected]:orientation] property. Within the other
* dimension, all children are allocated the same size. Of course, the
* [[email protected]:halign] and [[email protected]:valign] properties
* can be used on the children to influence their allocation.
*
* Use repeated calls to [[email protected]] to pack widgets into a
* `GtkBox` from start to end. Use [[email protected]] to remove widgets
* from the `GtkBox`. [[email protected]_child_after] can be used to add
* a child at a particular position.
*
* Use [[email protected]_homogeneous] to specify whether or not all children
* of the `GtkBox` are forced to get the same amount of space.
*
* Use [[email protected]_spacing] to determine how much space will be minimally
* placed between all children in the `GtkBox`. Note that spacing is added
* *between* the children.
*
* Use [[email protected]_child_after] to move a child to a different
* place in the box.
*
* # CSS nodes
*
* `GtkBox` uses a single CSS node with name box.
*
* # Accessibility
*
* `GtkBox` uses the %GTK_ACCESSIBLE_ROLE_GROUP role.
*/
public open class Box(
public val boxPointer: CPointer<GtkBox>,
) : Widget(boxPointer.reinterpret()), Accessible, Buildable, ConstraintTarget, Orientable {
public override val AccessiblePointer: CPointer<GtkAccessible> = boxPointer.reinterpret()
public override val BuildablePointer: CPointer<GtkBuildable> = boxPointer.reinterpret()
public override val ConstraintTargetPointer: CPointer<GtkConstraintTarget> =
boxPointer.reinterpret()
public override val OrientablePointer: CPointer<GtkOrientable> = boxPointer.reinterpret()
/**
* The position of the baseline aligned widgets if extra space is available.
*/
public var baselinePosition: BaselinePosition
/**
* Gets the value set by gtk_box_set_baseline_position().
*/
get() {
val cReturn = gtk_box_get_baseline_position(boxPointer)
return cReturn!!.let { gtk ->
BaselinePosition.valueOf(gtk)
}
}
/**
* Sets the baseline position of a box.
*
* This affects only horizontal boxes with at least one baseline
* aligned child. If there is more vertical space available than
* requested, and the baseline is not allocated by the parent then
* @position is used to allocate the baseline with respect to the
* extra space available.
*/
set(position) {
gtk_box_set_baseline_position(boxPointer, position.value)
}
/**
* Whether the children should all be the same size.
*/
public var homogeneous: Boolean
/**
* Returns whether the box is homogeneous (all children are the
* same size).
*/
get() {
val cReturn = gtk_box_get_homogeneous(boxPointer)
return cReturn!!.bool
}
/**
* Sets whether or not all children of @box are given equal space
* in the box.
*/
set(homogeneous) {
gtk_box_set_homogeneous(boxPointer, homogeneous.gtk)
}
/**
* The amount of space between children.
*/
public var spacing: Int
/**
* Gets the value set by gtk_box_set_spacing().
*/
get() {
val cReturn = gtk_box_get_spacing(boxPointer)
return cReturn!!
}
/**
* Sets the number of pixels to place between children of @box.
*/
set(spacing) {
gtk_box_set_spacing(boxPointer, spacing)
}
/**
* Adds @child as the last child to @box.
*/
public fun append(child: Widget): Unit {
gtk_box_append(boxPointer, child.pointer.reinterpret())
}
/**
* Inserts @child in the position after @sibling in the list
* of @box children.
*
* If @sibling is %NULL, insert @child at the first position.
*/
public fun insertChildAfter(child: Widget, sibling: Widget): Unit {
gtk_box_insert_child_after(boxPointer, child.pointer.reinterpret(), sibling.pointer.reinterpret())
}
/**
* Adds @child as the first child to @box.
*/
public fun prepend(child: Widget): Unit {
gtk_box_prepend(boxPointer, child.pointer.reinterpret())
}
/**
* Removes a child widget from @box.
*
* The child must have been added before with
* [[email protected]], [[email protected]], or
* [[email protected]_child_after].
*/
public fun remove(child: Widget): Unit {
gtk_box_remove(boxPointer, child.pointer.reinterpret())
}
/**
* Moves @child to the position after @sibling in the list
* of @box children.
*
* If @sibling is %NULL, move @child to the first position.
*/
public fun reorderChildAfter(child: Widget, sibling: Widget): Unit {
gtk_box_reorder_child_after(boxPointer, child.pointer.reinterpret(),
sibling.pointer.reinterpret())
}
public companion object {
public fun CPointer<GtkBox>?.wrap(): Box? = this?.wrap()
public fun CPointer<GtkBox>.wrap(): Box = Box(this)
}
} If you want to try the generator yourself you can checkout this project: https://gitlab.com/gtk-kt/gir-kt If you want to jump in for a chat with us, we are available on the official Matrix instance for the project: https://matrix.to/#/#gtk-kt:matrix.org |
Beta Was this translation helpful? Give feedback.
-
Hello, I know that this is a weird request, so feel free to just say no, but I was wondering if you will be open to help the
gtk-kt
project ^^The
gtk-kt
project is focused on Kotlin native, and not JNA so isn't exactly a direct competitor of your project.Currently there is only one maintainer that started writing the bindings manually but now he's working on a GIR generator for the Kotlin native code. But it isn't an easy task to do without previous knowledge of GIR so I was wondering if you could help us.
If you are wondering who am I, I'm just an Android developer that would love to be able to write GTK application in Koltin native. I started contributing to the
gtk-kt
project, very recently and, since I do not have a lot of C interop knowledge, my contributions are mostly on Gradle and pure Kotlin code level. And maybe a little of PR ^^.Beta Was this translation helpful? Give feedback.
All reactions